简体   繁体   中英

How to take multiple input in a single line in python

I am using list comphrensions for this:

x = [i for i in int(raw_input("Enter Input:")).split(",")]
Enter Input : 1 2 3 4 5

But it throws the error:

Traceback (most recent call last):
File "python", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1 2 3 4 5'

Can someone please sort it out.

x = [int(i) for i in raw_input("Enter Input:").split(" ")]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM