+ 2
splitlines only returns first list item?
Im trying to use x.splitlines() to separate a three line input into three separate pieces of data to work with individually. However for some reason im only getting the first line, instead of a list of each line. Why is this? x=input() in_list=x.splitlines() print(in_list)
8 odpowiedzi
+ 8
Randy Ziegler , how are you doing a "3 line input" with one input() call? May be you can give an example? Thanks!
+ 7
Randy Ziegler here is an example of splitline() and split()
https://code.sololearn.com/cT7CrAQbk7gy/?ref=app
+ 6
Randy Ziegler , the task description means that you have to do 3 inputs. Sample used is:
'Eric'
2
'Adam Caroline Rebecca Frank'
- the first input can be taken as it is
- the second input has to be converted to an int (as input returns everything as string)
- the third input is a space separated string. this has to be splitted at the spaces
For the last task you can just use split(' '), this results in a list with 4 elements
+ 4
ahhhh, you must be doing this here in SoloLearn. Multiline input counts as multiple inputs being gathered here. Your code accepts one input, so the rest are forgotten
+ 2
in_list = x.split('\n') #?
+ 2
Does the same thing, I dont understand why
+ 2
Lothar its the 'new driver's license' code coach, it says the input is a string, an integer, and another string and I took it to mean a single input of all three that you are responsible for separating