Ich bin neu in Python und ich bin gerade dabei, die Syntax zu lernen. Ich möchte eine Karte erstellen (wie in Java, aber ich verstehe, dass sie etwas anderes in Python genannt werden kann), so würde ich den Code annehmen, so etwas wie diesesWie organisiere ich eine Karte In Python
map = {}
map.append("somestring": 12)
map.append("anotherstring": 10)
map.append("yetanotherstring": 15)
'''
then organize the map by the numbers from largest to smallest
so if I were to then run through the map with a for loop it would
print
"yetanotherString" : 15
"somestring" : 12
"anotherstring" : 10
'''
aussehen könnte ich ahnungslos bin In fast jedem Schritt Dieser Prozess von der Deklaration einer "Karte" zu organisieren von den INTs. Obwohl es von den Ints organisiert wird, ist mein größtes Problem.
Wenn Sie Python neu sind, dann verbringen Sie einige Zeit mit [das Tutorial] (https://docs.python.org/3/tutorial/index.html). In Ihrem Fall suchen Sie nach [Wörterbüchern] (https://docs.python.org/3/tutorial/datastructures.html#dictionaries). – poke
Bitte nennen Sie Ihre Variable map nicht, weil Sie die eingebaute Funktion [map] (https://docs.python.org/3/library/functions.html#map) überschreiben. – Matthias