'How to save a user's input as a variable?
I am learning Python and trying to make a program that asks:
- Where are you from? if user responds "Buenos Aires" the program asks
- Should we kill em all?
That part is done. What I want to do next is make it so that if the user responds to 2 with "yes" the program responds with "Damn straight soldier." Best I can think of is that I should have the user's input from 2 saved as a variable and write something that says if that variable = yes then print("damn straight soldier"). But how do I designate the user input in response to 2 as a variable?
Current code:
user_location = input("where are you from?:")
if user_location == "Buenos Aires":
print(input("should we kill em all?:"))
Round 2:
user_location = input("where are you from?:")
Buenos_Aires = input("should we kill em all?:")
if user_location == "Buenos Aires":
print(Buenos_Aires)
if Buenos_Aires == "yes":
print("damn straight soldier")
Round 3:
user_location = input("where are you from?:")
if user_location == "Buenos Aires":
print(Buenos_Aires)
Buenos_Aires = input("should we kill em all?:")
if Buenos_Aires == "yes":
print("damn straight soldier")
Round 4: (still getting "yes" as the end here)
user_location = input("where are you from?:")
if user_location == "Buenos Aires":
kill_em_all = input("should we kill em all?:")
if kill_em_all == "yes":
print("Damn Straight Soldier")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

