Can i put anything in for x
Clash Royale CLAN TAG#URR8PPP
Can i put anything in for x
I am learning how to code in python so I'm wondering if we can put anything in for x (key in this instance):
for key in prices:
print key
print "price: %s" % prices[key]
print "stock: %s" % stock[key]
Welcome to SO. When you swapped out 'key' for 'x' or for 'skittle' or for 'wumpus', what did you find?
– dfundako
35 secs ago
x
is just a variable. It can be any valid python identifier.– juanpa.arrivillaga
just now
x
1 Answer
1
Yes, you can put any name there that you wish -- just as long as it's a valid variable name in Python. key
is going to be the variable name for each item inside the for
block.
key
for
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Anything that has a string representation
– roganjosh
40 secs ago