[Solved] what is the difference? Why the first one give me an error?


When you call dict() with an iterable it expects that iterable to return pairs of values, that it can use as keys and values to create the dict. So, these examples are all valid:

dict([('key', 'value'), ('other_key', 'other_value')])
dict(['ab', 'bc', 'dd'])  # 'ab' is pretty much equivalent to a list ['a', 'b']
dict([['a', 1], ['b', 2]])
dict(['key value'.split(), 'other_key other_value'.split()])

So, number one would work if you input character pairs, like aa bb cc. It will not work for any other case.

Second one will make inputs iterable, which is pretty much the same as wrapping it in a list. It will work for any input value that can be split into a pair. These would be valid:

key value
other_key other_value
aa

These would be invalid (not pairs):

key value other_value
a
aaa

So it all depends on the input.

solved what is the difference? Why the first one give me an error?