+ 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
3 Antworten
+ 1
Well, the x for x is discussed later in the Python tutorial, and I don't think you've gotten to it yet.
+ 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"].
+ 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