0

Multiple input python

How to get multiple input (string as well as number)in a list using for loop in python 3 ?? I want to sort them with names as key !!

24th Mar 2019, 2:36 PM
Pranjal
Pranjal - avatar
10 Réponses
+ 3
hi Pranjal, can you please provide a list as sample so that we can get a feeling what you want to achieve? Thanks.
24th Mar 2019, 3:00 PM
Lothar
Lothar - avatar
+ 3
hi Pranjal, I have prepared for you some code attached in a py file. When you run it in Playground, you will be prompted for an input. Enter a name and an age, separated by comma. e.g. Claude,54 Code is with comments and also output is with some information. Hope this helps. https://code.sololearn.com/cKA5lpr9ICqR/?ref=app
25th Mar 2019, 12:00 PM
Lothar
Lothar - avatar
+ 2
Pranjal, thanks for your information. That helps. A last question: if you say: I want to arrange them with : 1. Key = Name 2. Key = Age does this mean that you want to get them sorted by Name OR by Age? Or do you mean that the key for sorting should be a combination of both ‘fields’ : Name + Age?
24th Mar 2019, 5:02 PM
Lothar
Lothar - avatar
+ 2
Pranjal, if you like - yes!
25th Mar 2019, 12:52 PM
Lothar
Lothar - avatar
0
Let there be n=3 names with their ages : John 22 Dave 26 Robert 20 I want to arrange them with : 1. Key = Name 2. Key = Age here there are 3 inputs.. i want for n inputs
24th Mar 2019, 3:50 PM
Pranjal
Pranjal - avatar
0
~ swim ~ I got you earlier but my question was something different.
24th Mar 2019, 5:16 PM
Pranjal
Pranjal - avatar
0
Lothar I want to give user an option, whether they want to sort by name or by age . In both the cases, key will be different . Also, when i'll print the sorted list, i want the complete info to be printed !!
24th Mar 2019, 5:19 PM
Pranjal
Pranjal - avatar
0
Ok. Thanks a lot Lothar !! Should i send you my code too ?
25th Mar 2019, 12:04 PM
Pranjal
Pranjal - avatar