while int(input("choose a number")) != 5 :
Say I wanted to see what number was input. Is there an indirect way to get at that?
EDIT Im probably not being very clear lol. . I know that in the debugger, you can step through and see what number gets input. Is there maybe a memory hack or something like it that lets you get at 'old' data after the fact?
Nope - you have to assign it... Your example could be written using the two-argument style iter
though:
for number in iter(lambda: int(input('Choose a number: ')), 5):
print number # prints it if it wasn't 5...
Do something like this. You don't have to assign, but just make up an additional function and use it every time you need to do this. Hope this helps.
def printAndReturn(x): print(x); return(x)
while printAndReturn(int(input("choose a number"))) != 5 :
# do your stuff
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With