简体   繁体   中英

Take multiple inputs from user seperated by lines

I've been trying different variations of this simple piece of code and it won't take the input. Both split('\n') and splitlines() don't work.

a,b = input().split('\n')
#User input as given below
2
3
4

When I try to give the input on different lines, I get the error ' ValueError: not enough values to unpack'. Is there a way to work around this without assigning the values to a list but different variables? Please help.

I've been trying different variations of this simple piece of code and it won't take the input. Both split('\n') and splitlines() don't work.

a,b = input().split('\n')
#User input as given below
2
3
4

When I try to give the input on different lines, I get the error ' ValueError: not enough values to unpack'. Is there a way to work around this without assigning the values to a list but different variables? Please help.

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