I’m new to Python but not new to programming. Please correct me if this is wrong.
Each letter has a numeric value. So the names are sorted by the NUMERIC value of the letters. Add in names in lowercase like ‘michal’ and ‘pepa’ and sort the list, the print the list. Capital letters have a value before lowercase letters, so a capital A has a value of 65, but lowercase has has a higher value.
Also please format all your code so we can just copy and paste it and run it ourselves to help you. You will get more help that way.
Also when I copied your code your code uses the wrong quotes in the first line jmena = [ and for all those entries in the list. Never use a word processor to write code even if it saves as plain text as it can mess things up. Use a proper text editor like Notepad++ (Downloads | Notepad++) or PSPad (PSPad download - freeware text editor) or something else. Those two are free.
You will need a text editor which can show hidden characters because Python is real picky about indentation. Indentation must be all spaces or all tabs, not mixed.
Here’s the program I used and the output I got:
jmena = [
'Michal', 'Pepa', 'Honza',
'Pavel', 'Lukas', 'Matej',
'Iva', 'Klara', 'Jana',
'Honza', 'Vasek','Milan',
'Michal', 'michal', 'jana'
]
kopie_jmen = jmena.copy()
for i in range(len(kopie_jmen)):
for j in range(i + 1, len(kopie_jmen)):
if kopie_jmen[i] > kopie_jmen[j]:
kopie_jmen[i], kopie_jmen[j] = kopie_jmen[j], kopie_jmen[i]
print(kopie_jmen)
Output:
['Honza', 'Honza', 'Iva', 'Jana', 'Klara', 'Lukas', 'Matej', 'Michal', 'Michal', 'Milan', 'Pavel', 'Pepa', 'Vasek', 'jana', 'michal']