Multiple input python | SoloLearn: Learn to code for FREE!

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 !!

3/24/2019 2:36:36 PM

Pranjal

10 Answers

New Answer

+3

hi Pranjal, can you please provide a list as sample so that we can get a feeling what you want to achieve? Thanks.

+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

+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?

+2

Pranjal, if you like - yes!

0

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

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

0

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

0

~ swim ~ I got you earlier but my question was something different.

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 !!

0

Ok. Thanks a lot Lothar !! Should i send you my code too ?