File lines question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

File lines question

File contains 3 rows of names. How can I print it out so itโ€™s in ascending order of surname? Thank you and please explain For row in file: Info = row.split(โ€œ,โ€) Username=info[0] Firstname=info[1] Surname=info[3] Print(username, firstname, surname)

12th Feb 2022, 9:25 PM
Darkpidgeon 14
1 Answer
+ 2
You can use sort method info.sort() #index 3 out of range, may you mean info[2]
12th Feb 2022, 9:51 PM
Jayakrishna ๐Ÿ‡ฎ๐Ÿ‡ณ