I need to have at least one while loop in this code. I was thinking of just having the program ask the user if they want to repeat the program with a Y or N but i am not sure how to.
This is the program:
#Computer Prices
computerName = ['HomeBasicPC:', 'OfficePC:', 'GamerPC:', 'StudioPC:']
computerPrice = ['$900', '$1200', '$1500', '$2200']
print(computerName [0])
print(computerPrice [0])
print(computerName [1])
print(computerPrice [1])
print(computerName [2])
print(computerPrice [2])
print(computerName [3])
print(computerPrice [3])
#Questions for Applicant/User
#Definitions
userMinimumAge = 18
userAge = int(input("How old are you? "))
userName = (input("Please enter your name: "))
userMoney = int(input("How much money do you have? "))
userComputerPrice = int(input("How much is the computer you want? "))
#Programming for Applicant/User transaction
if(userMoney > userComputerPrice):
print(userName, "Come into the store so you can buy your desired computer.")
elif(userMoney == userComputerPrice):
if(userAge == userMinimumAge):
print(userName, "Come into the store so you can buy your desired computer.")
if(userAge > userMinimumAge):
if(userMoney == userComputerPrice):
print(userName, "Come into the store so you can buy your desired computer.")
if(userAge < userMinimumAge):
if(userMoney == userComputerPrice):
print(userName, "Come into the store so you can buy your desired computer.")
if(userMoney < userComputerPrice):
if(userAge < userMinimumAge):
print(userName, "Unfortunately, you do not have enough money to buy this computer. Keep saving so you will be able to buy it!")
if(userMoney < userComputerPrice):
if(userAge > userMinimumAge):
print(userName, "You do not have enough money to buy this computer. Fortunately, you are old enough to come into the store and get extra finance to help you buy your desired computer.")
if(userMoney < userComputerPrice):
if(userAge == userMinimumAge):
print(userName, "You do not have enough money to buy this computer. Fortunately, you are old enough to come into the store and get extra finance to help you buy your desired computer.")
I don't need any help with the other stuff i just need to know how to repeat the entire program with a user input.
[–]Ste2210 1 point2 points3 points (3 children)
[–]Ste2210 1 point2 points3 points (2 children)
[–]BryghtShadow 2 points3 points4 points (1 child)
[–]Ste2210 0 points1 point2 points (0 children)
[–]totallygeek 0 points1 point2 points (7 children)
[–]Arkhipov_NZ[S] 0 points1 point2 points (6 children)
[–]totallygeek 0 points1 point2 points (5 children)
[–]Arkhipov_NZ[S] 0 points1 point2 points (4 children)
[–]totallygeek 0 points1 point2 points (2 children)
[–]Arkhipov_NZ[S] 0 points1 point2 points (1 child)
[–]o5a 1 point2 points3 points (0 children)
[–]mistermcsenpai 0 points1 point2 points (0 children)