+ 1

Not sure what this line of code does?

Been working on some sample problems to practice python. In the solution, thereā€™s a line: items=[x for x in raw_input().split(ā€˜,ā€™)] Iā€™m just not entirely sure what the x for x means

27th Sep 2018, 8:17 PM
Spencer
3 Answers
+ 1
Well, the x for x is discussed later in the Python tutorial, and I don't think you've gotten to it yet.
27th Sep 2018, 8:54 PM
LunarCoffee
LunarCoffee - avatar
+ 4
That's some highly inefficient code there. Just input().split(',') will do (raw_input() is Python 2, which I strongly suggest you move away from. Python 3 uses input()). What input().split(',') does, on the other hand, is it gets the user's input, and splits it every time a comma appears into a list of strings. If the input is "bc,def,ghi", then the variable items will be ["abc", "def", "ghi"].
27th Sep 2018, 8:22 PM
LunarCoffee
LunarCoffee - avatar
+ 1
LunarCoffee yeah, i use python 3 and was aware to the outdated inout command. im just new to some of the terminolgoy and have seen ā€œx for xā€ pop up before like that and wasnt sure what it does
27th Sep 2018, 8:37 PM
Spencer