I have been trying for a while to be able to access my recently returned value and use it in if statements without having to recall the value.
Basically I have a while loop that calls a function that allows the user to input and then returns the input back into the loop.
while selection() != 0: ## Calls the "WHAT WOULD YOU LIKE TO DO" list and if it is 0 quits the script
input() ## just so it doesn't go straight away
if selection.return == 1: ## This is what I would like to happen but not sure how to do it... I've googled around a bit and checked python docs
See if I put:
if selection() == 1:
it will work but displays the "WHAT WOULD YOU LIKE TO DO" text again...
I'm sorry if this is an obvious solution, but the help would be very much appreciated :)
That's why you would store the result in a variable, so you can reference it in the future. Something like:
sel = selection()
while sel != 0:
input()
if sel==1:
...
sel = selection()
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