Can i put anything in for x

The name of the pictureThe name of the pictureThe name of the pictureClash 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]





Anything that has a string representation
– roganjosh
40 secs ago





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.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard