How do I gather user numerical input into a list in Python?

后端 未结 2 1258
隐瞒了意图╮
隐瞒了意图╮ 2020-12-12 08:15

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         


        
2条回答
  •  盖世英雄少女心
    2020-12-12 08:58

    You can use this one line:

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

    Notes:

    • Read about PEP-8
    • Read about split
    • List comprehension

提交回复
热议问题