10 AnswersNew Answer
hi Pranjal, can you please provide a list as sample so that we can get a feeling what you want to achieve? Thanks.
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
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?
Pranjal, if you like - yes!
Pranjal Say you want to read 3 values (sting, values pair) using for loop then in the input box enter your values as A 1 press enter B 2 press enter C 3 press submit do not put everything on same line else you will get exception
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
Pranjal That is what i told you i.e read pair It seems you are interprating my input example as A 1, B 1 and C 1 but not your fault i should have been more clear. Actually the data is like this A , 1 B , 2 C, 3 i forgot to put comma between them, which probably confused you
~ swim ~ I got you earlier but my question was something different.
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 !!
Ok. Thanks a lot Lothar !! Should i send you my code too ?