python one-line input referenced twice -
How can I reference the input twice in a line code? Ex:
my_word = input () print ("hey" if my_word == my_word other "bye")
You are referring it once, so it's easy:
print ("hey" if input (). Although you can argue that this line of code is very high, and can be difficult to maintain. It breaks into two rows making it easy to maintain, and for example it allows you to set a breakpoint on the line and inspect the value in my_word if the You wish For academic reasons, here is a possible solution to evaluate an expression, but to use it several times in a statement: Understand the list. ( This is a terrible, horrible idea, and you should not do that. I mean. ) [print I.isdigit () and "bye" in I (Input (),)]
Comments
Post a Comment