Home > other >  Novice small problems
Novice small problems

Time:11-16

List1=[' 1 ', '2')
List2=[' a ', 'b']
Dict1={' 1 ': list1 [o], list1 [1]}
Print (adict)

So why write error, novice to guide

CodePudding user response:

Print (adict)

Adict is a new variable, empty

CodePudding user response:

reference 1st floor tianfang response:
print (adict)

Adict is a new variable, empty

Dict1 that line list yuan plain fittings to the dictionary for it

CodePudding user response:

reference Andy liu reply 2 floor:
Quote: refer to 1st floor tianfang response:
print (adict)

Adict is a new variable, empty

Dict1 plain fittings for it in the dictionary that line the list yuan


You should also print dict1 ah

CodePudding user response:

1, dict1={' 1 ': list1 [o], list1 [1]} this you should be to want to write a dictionary, dictionary format is the key: value mode is 1 to 1 you this much for you can like this: 1 dict1={' 1' : list1}
2, print (adict) adict is a variable, no assignment

CodePudding user response:

reference 4 floor qq_20375703 response:
1, dict1={' 1 ': list1 [o], list1 [1]} this you should be to want to write a dictionary, dictionary format is the key: value mode is 1 to 1 you this much for you can like this: 1 dict1={' 1' : list1}
2, print (adict) adict is a variable, no assignment

There can be only one value cost? Wrong!

CodePudding user response:

Check code, print (adict) adict no assignment, how to output,
Data dictionary is the key: value the key value of form, the value is a data value, can be an integer, can be a string, or it can be a fission, and even a dictionary, {' 1 ': list1 [0], list1 [1]} is obviously not in conformity with the format, according to your reply, I guess you might be want to write this {' 1' : list1 [0], '2' : the list [1]}

CodePudding user response:

reference 5 floor Andy liu reply:
Quote: refer to 4th floor qq_20375703 response:
1, dict1={' 1 ': list1 [o], list1 [1]} this you should be to want to write a dictionary, dictionary format is the key: value mode is 1 to 1 you this much for you can like this: 1 dict1={' 1' : list1}
2, print (adict) adict is a variable, no assignment

There can be only one value cost? Wrong!


Dictionary is a key corresponding to a value, but the value can be a string, a dictionary, the list data type, etc

CodePudding user response:

 
List1=[' 1 ', '2')
List2=[' a ', 'b']
Dict1={' 1 ': [list1 [0], list1 [1]]}
  • Related