Skip to content Skip to sidebar Skip to footer

How Do I Gather User Numerical Input Into A List In Python?

I'm new to Python and am trying to make a simple program to calculate mean median and mode from numbers input by user. So far I have: num=[] UserNumbers=int(input('Enter number seq

Solution 1:

You have to parse the answer if you want it this way.

UserNumbers=input("Enter number sequence separated by spaces: ")
nums = [int(i) for i in UserNumbers.split()]

EDIT:

Duplicate of this question

Solution 2:

You can use this one line:

user_numbers = [int(num) for num inraw_input
                ("Enter number sequence separated by spaces: ").split()]

Notes:

Post a Comment for "How Do I Gather User Numerical Input Into A List In Python?"