Get a list of numbers as input from the user

前端 未结 17 1133
生来不讨喜
生来不讨喜 2020-11-21 22:26

I tried to use raw_input() to get a list of numbers, however with the code

numbers = raw_input()
print len(numbers)

the input

17条回答
  •  鱼传尺愫
    2020-11-21 22:59

    Get a list of number as input from the user.

    This can be done by using list in python.

    L=list(map(int,input(),split()))
    

    Here L indicates list, map is used to map input with the position, int specifies the datatype of the user input which is in integer datatype, and split() is used to split the number based on space.

    .

提交回复
热议问题