Skip to content
Advertisement

(Python).format() is output incorrectly

JavaScript

If you run

JavaScript

Come out like this or

JavaScript

It comes out like this

What I want is that the elements except abc1 are inserted as ff and a randomly selected value is output. For example

JavaScript

Advertisement

Answer

Given your desired output, you are looking to create new dictionaries, not string representations of dictionaries, so this will do:

JavaScript

If you still need a string representation of the dictionary you can get it with

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement