Skip to main content

All Questions

5 votes
0 answers
583 views

In Python, can I specify a range of string indices in a return statement placeholder?

I'm practising using Python's .format method. The first block of code below can print first_name and the first letter of last_name. In the second block of code I was experimenting with the index in ...
Gospel77's user avatar
  • 153
1 vote
1 answer
2k views

Python named placeholders with nested dictionary (JSON)

Im working with format and named placeholders and trying to figure out: How is it possible to access nested items (eg. JSON objects) using named placeholders in Python? For example data = { '...
Philip's user avatar
  • 974
2 votes
1 answer
4k views

String replace/format placeholder values in a nested python dictionary

Let's say I have a nested dictionary like this: example_dict = { 'key_one': '{replace_this}', 'key_two': '{also_replace_this} lorem ipsum dolor', 'key_three': { 'nested_key_one': '...
user1087973's user avatar
  • 1,136
43 votes
6 answers
85k views

How to do string formatting with placeholders in Java (like in Python)?

I am new to Java and am from Python. In Python we do string formatting like this: >>> x = 4 >>> y = 5 >>> print("{0} + {1} = {2}".format(x, y, x + y)) 4 + 5 = 9 >>>...
user1757703's user avatar
  • 3,015