Let’s say that I have a line with: a = input("Enter your name and age:")
How can I make the variable “a” store each section of the input, lets say “George 25” as “George, 25” either as a standard variable or a list? All I want to do is be able to store user input as separate elements in a list or variable so that input with words separated by a space would become separate elements in a variable. Is this clear enough? I am using Python 3.0
Let’s say that I have a line with: a = input(Enter your name and
Share
How about using str.split():
This creates a list of each space-separated word in the input.
Then you can access each part as:
Is that what you’re after ?