Hello forum,
Im very much a beginner in programming. I have been spening the last couple of hours to find a solution for this simple problem. So now was the time to join the forum and get help.
I have simplified the problem area of my code in this small code.
I want the user to make a choice in one definition and then have another definition respond to that choice.
type in "1" should give "ONE"
type in 2 should give "TWO"
However, if I run the following code and type in "1" I will not get "ONE" as a response but "TWO" . What am I doing wrong? (why is "1" in one definition not equal to "1" in the other)?
I know I am missing something basic but I just can't figure out waht it is.
Im very much a beginner in programming. I have been spening the last couple of hours to find a solution for this simple problem. So now was the time to join the forum and get help.
I have simplified the problem area of my code in this small code.
I want the user to make a choice in one definition and then have another definition respond to that choice.
type in "1" should give "ONE"
type in 2 should give "TWO"
However, if I run the following code and type in "1" I will not get "ONE" as a response but "TWO" . What am I doing wrong? (why is "1" in one definition not equal to "1" in the other)?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
def choice(): choice = "0" while choice ! = "1" and choice ! = "2" : choice = input ( "Type 1 og 2 " ) return (choice) def response(choice): if choice = = "1" : print ( "ONE" ) else : print ( "TWO" ) choice() response(choice) |