I am having trouble with my for loops working - python
My For loops don't seem to be "activating" or working. I am writing a program about the Oregon trail and I am working on the "shop" part. Here is what its been doing,
First it was asking the same question "How much food would you like to buy" until I pressed E to break out of it. Now its not doing the math or activating the for loop. Here is the code i'm working with:
import random
global all
global PlayerPerk
#Organ Trail Start--
print("You may:")
print("1. Travel the road")
print("2. Learn More about the road")
choiceStart = input("What is your choice? ")
def Shop(PlayerPerk, money):
global all
#intro
print("Before You set off on your Journey, you will need some supplies to survive the dangerous trail. You will need Food, Ammo, Spare Parts, Clothing, and Oxen")
#money define
if PlayerPerk == "1":
print("You are A cop. You have $400 to spend.")
money = 400
elif PlayerPerk == "2":
print("You are a Clerk. You have $700 to spend.")
money = 700
elif PlayerPerk == "3":
print("You are a Banker. You have $1600 to spend.")
money =1600
print("Welcome to My shop! First thing, how much Food would you like to buy?")
#Food -------------------------------------------------------------------------------
FoodToBuy = input("How Much food would you like (each cost $2):")
MoneySubtract = FoodToBuy*2
for i in range(1,1000):
if FoodToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent: ",MoneySubtract, "You now have: ",money)
Food = FoodToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
elif FoodToBuy == "e":
break
#Ammo --------------------------------------------------------------------------------
print("Now lets buy some Ammo!")
AmmoToBuy = input("How Much Rifle Ammo would you like to buy (each box cost $5):")
MoneySubtract = AmmoToBuy*5
for i in range(1,1000):
if AmmoToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent:",MoneySubtract, "You now have: ",money)
Ammo = AmmoToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
elif AmmoToBuy=="e":
break
#Spare Parts---------------------------------------------------------------------------
print("Now lets buy some Spare Parts!")
SparePartsToBuy = input("How much Spare Parts would you like to buy (each costs $20 [max of 9]):")
MoneySubtract = SparePartsToBuy*20
for i in range(1,1000):
if SparePartsToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent:", MoneySubtract, "You now have: ",money)
SpareParts = SparePartsToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
elif AmmoToBuy=="e":
break
else:
print("Unknown input!")
Shop(PlayerPerk, 0)
#chlothing-----------------------------------------------------------------------------
print("Now, you need to buy some chlothes!")
ClothesToBuy = input("How many Clothes would you like to buy (each pair costs $5):")
MoneySubtract = ClothesToBuy*5
for i in range(1,1000):
if ClothesToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent:", MoneySubtract, "You now have: ",money)
SpareParts = ClothesToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
elif AmmoToBuy=="e":
break
else:
print("Unknown input!")
Shop(PlayerPerk, 0)
#oxen-------------------------------------------------------------------------------------
print("Finally, you need to buy some Ox!")
OxenToBuy = input("How many Oxen would you like to buy (each costs $30):")
MoneySubtract = OxenToBuy*30
for i in range(1,1000):
if OxenToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent:", MoneySubtract, "You now have: ",money)
SpareParts = OxenToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
if AmmoToBuy=="e":
break
else:
print("Unknown input!")
Shop(PlayerPerk, 0)
#----------------------------------------------------------------------------------------------
def MonthStart(PlayerPerk):
global all
print("It is 1848. Your jumping off place for oregon is Independence, Missouri. You must decide which month to leave Indepence.")
print("1. March")
print("2. April")
print("3. May")
print("4. June")
print("5. July")
print("6. ask for advice")
StartingMonth = input("What is your choice? ")
if StartingMonth == ("6"):
global all
print("You attend a public meeting held for 'folks with the California - Oregon fever.' You're told:")
print("If you leave too early, there won't be any grass for your oxen to eat.")
print("if you leave to late, you may not get to Oregon before winter comes.")
print("If you leave at just the write time, there will be green grass and the weather will still be cool.")
exMonthChoice = input("Would you like to stop viewing?(y/n) ")
if exMonthChoice ==("Y" or "y"):
MonthStart(PlayerPerk)
elif exMonthChoice == ("N"or"n"):
print("Still viewing")
else:
print("Unknown usage.")
elif StartingMonth == ("1"):
Month = "March"
print("You chose: ", Month )
Shop(PlayerPerk,0)
elif StartingMonth == ("2"):
Month = "April"
print("You chose: ", Month )
Shop(PlayerPerk,0)
elif StartingMonth == ("3"):
Month = "May"
print("You chose: ", Month )
Shop(PlayerPerk,0)
elif StartingMonth == ("4"):
Month = "June"
print("You chose: ", Month)
Shop(PlayerPerk,0)
elif StartingMonth == ("5"):
Month = "July"
print("You chose: ", Month)
Shop(PlayerPerk,0)
global all
############################
#NAMING
def NAMING(PlayerPerk):
global all
print("Now lets name your person")
Name1 = input("What is the name of the Wagon leader ")
Name2 = input("What is the name of the 2nd person in the family? ")
Name3 = input("What is the name of the 3rd person in the family? ")
Name4 = input("What is the name of the 4th person in the family? ")
Name5 = input("What is the name of the 5th person in the family? ")
NameVerification = input("Are these names correct?")
if NameVerification == ("Y" or "y"):
MonthStart(PlayerPerk)
elif NameVerification ==("N" or "n"):
NAMING(PlayerPerk)
#Start OCCUPATION
def Occupation():
global all
############################################################
print("Many people find themselves on the road. You may : ")
print("1. Be a cop from Kentucky.")
print("2. Be a clerk from Jersey City.")
print("3. Be a Banker from Boston.")
print("4. Find out the differences between these choices.")
############################################################
jobChoice = input("What is your choice? ")
if jobChoice == ("4"):
print("Traveling to Oregon isn't easy! But if you are a banker, you'll have more money for supplies and services than a cop or a clerk.")
print(" But, a cop has a higher chance of haveing a successful hunt!")
print("And a Clerk has a higher survival rate!")
exChoice1 = input("Would you like to stop viewing your options?(y/n) ")
if exChoice1 == ("y" or "Y"):
Occupation()
###############################
elif jobChoice ==("1"):
print("You chose to be a cop from Kentucky!")
PlayerPerk = ("1")
NAMING(PlayerPerk)
elif jobChoice == ("2"):
print("You chose to be a clerk from Jersey City!")
PlayerPerk = ("2")
NAMING(PlayerPerk)
elif jobChoice == ("3"):
print("You chose to be a Banker from Boston!")
PlayerPerk = ("3")
NAMING(PlayerPerk)
#Call choices
if choiceStart == ("1"):
Occupation()
And here is the specific code I'm having troubles with:
def Shop(PlayerPerk, money):
global all
#intro
print("Before You set off on your Journey, you will need some supplies to survive the dangerous trail. You will need Food, Ammo, Spare Parts, Clothing, and Oxen")
#money define
if PlayerPerk == "1":
print("You are A cop. You have $400 to spend.")
money = 400
elif PlayerPerk == "2":
print("You are a Clerk. You have $700 to spend.")
money = 700
elif PlayerPerk == "3":
print("You are a Banker. You have $1600 to spend.")
money =1600
print("Welcome to My shop! First thing, how much Food would you like to buy?")
#Food -------------------------------------------------------------------------------
FoodToBuy = input("How Much food would you like (each cost $2):")
MoneySubtract = FoodToBuy*2
for i in range(1,1000):
if FoodToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent: ",MoneySubtract, "You now have: ",money)
Food = FoodToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
elif FoodToBuy == "e":
break
#Ammo --------------------------------------------------------------------------------
print("Now lets buy some Ammo!")
AmmoToBuy = input("How Much Rifle Ammo would you like to buy (each box cost $5):")
MoneySubtract = AmmoToBuy*5
for i in range(1,1000):
if AmmoToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent:",MoneySubtract, "You now have: ",money)
Ammo = AmmoToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
elif AmmoToBuy=="e":
break
#Spare Parts---------------------------------------------------------------------------
print("Now lets buy some Spare Parts!")
SparePartsToBuy = input("How much Spare Parts would you like to buy (each costs $20 [max of 9]):")
MoneySubtract = SparePartsToBuy*20
for i in range(1,1000):
if SparePartsToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent:", MoneySubtract, "You now have: ",money)
SpareParts = SparePartsToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
elif AmmoToBuy=="e":
break
else:
print("Unknown input!")
Shop(PlayerPerk, 0)
#chlothing-----------------------------------------------------------------------------
print("Now, you need to buy some chlothes!")
ClothesToBuy = input("How many Clothes would you like to buy (each pair costs $5):")
MoneySubtract = ClothesToBuy*5
for i in range(1,1000):
if ClothesToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent:", MoneySubtract, "You now have: ",money)
SpareParts = ClothesToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
elif AmmoToBuy=="e":
break
else:
print("Unknown input!")
Shop(PlayerPerk, 0)
#oxen-------------------------------------------------------------------------------------
print("Finally, you need to buy some Ox!")
OxenToBuy = input("How many Oxen would you like to buy (each costs $30):")
MoneySubtract = OxenToBuy*30
for i in range(1,1000):
if OxenToBuy == int:
if money - MoneySubtract > 0:
money -= MoneySubtract
print("You spent:", MoneySubtract, "You now have: ",money)
SpareParts = OxenToBuy
MoneySubtract = 0
else:
print("Insufficent Funds!")
Shop(PlayerPerk,money)
if AmmoToBuy=="e":
break
else:
print("Unknown input!")
Shop(PlayerPerk, 0)
The only problem i'm having is making the for loops work. I plan on using all the variables as the code develops. If you know whats wrong or have any information on anything let me know! Thank you in advance!
Related
Turn/chance feature in following code is not working
I am trying to create a IPL/Fanstasy cricket simulators in which you create your team and play. You auction the players. In the auction function, I have added a turn feature, which means if the turn variable is even, then its your turn, if its odd, then its other bidders turn. def auction(money, turn, choice): if turn % 2 == 0: while True: print("It is your turn to choose a player.") while True: selected_player = str( input("Enter the name of the player you wish to choose(leave empty to skip):")) if selected_player in players: break elif selected_player == "": print("Turn Skipped") else: print("That player is not in your players") selected_player_bid = int(input("Enter the amount of money for which you wish to buy the player(leave " "empty to skip):")) if selected_player_bid > money: print("You dont have enough money to buy the player.") else: your_players.append(selected_player) print("Player bought") break break else: selected_player = random.choice(players) selected_player_bid = random.randint(1, 100000) print( f"{random.choice(bidders)} chooses {selected_player} for {selected_player_bid}.") print( "You can either type [p]ass let them take the player or type [c]hallenge to challenge them.") while True: choice = input("Challenge or pass: ") if choice.lower() == "challenge": break elif choice.lower() == "pass": break elif choice.lower() == "p": break elif choice.lower() == "c": break else: print("Not a valid command, please type again.") while choice.lower() == "challenge" or choice.lower() == 'c': bid = int(input("Enter your bid: ")) if bid > money: print("You do not have enough money.") elif bid < selected_player_bid: print("That is lower than the starting bid.") else: print(f"{selected_player} bought for {bid}") money = money - bid print("You have enough money.") your_players.append(selected_player) break if choice.lower() == "p" or choice.lower() == "pass": pass players.remove(selected_player) The usage of the function(This is where I was trying to fix the code). while True: if random_choice: turn = turn + 1 random_choice = bool(random.choice(binary_numbers)) auction(your_money, turn, choice) else: random_choice = bool(random.choice(binary_numbers)) auction(your_money, turn, choice) pass if len(players) == 0: break else: continue GitHub repo You can comment the fix or create a pull request. Thanking you in advance. I expected the code to randomly choose the bidder, either the player or the bots, but when I was fixing it, it was not doing so.
Horse Racing Simulation Loop
So I have this program that basically runs a horse betting simulation. When the user chooses the horse from a list of names I have created, my program returns a % that predicts the horse's chances of winning the race (I am still working on this so just don't mind it). However, the program asks the user if they want to change horses. If they do, they get to choose their horse again, if not, the program continues to the race. I want to make my program so that it only allows the user to change horses once to make it a gamble. Is there a way I can do that? If there are any other changes that should be made let me know! (Created in Python). code: import random import time # percentage for the chosen horse to win the race def Percent(): min = 1 max = 100 win = random.randint(min, max) print(win) # asks user if they want to change their chosen horse def Horserestart(): new_horse = input("Do you wan to change you horse? Type Y or N. ") if new_horse == "Y": Horse() elif new_horse == "N": New() # user chooses a horse def Horse(): print("Horses to bet on: Tyrone, Jamal, Jaquavious, Quandale, Quantavious, and Charlie.") horse_pick = input("What horse do you want to choose? ") if horse_pick == "Tyrone": option = print("You chose Tyrone, your chances of winning are: ") Percent() Horserestart() elif horse_pick == "Jamal": option = print("You chose Jamal, your chances of winning are: ") Percent() Horserestart() elif horse_pick == "Jaquavious": option = print("You chose Jaquavious, your chances of winning are: ") Percent() Horserestart() elif horse_pick == "Quandale": option = print("You chose Quandale, your chances of winning are: ") Percent() Horserestart() elif horse_pick == "Quantavious": option = print("You chose Quantavious, your chances of winning are: ") Percent() Horserestart() elif horse_pick == "Charlie": option = print("You chose Charlie, your chances of winning are: ") Percent() Horserestart() # user inputs their total money and bet amount def New(): while True: total_money = int(input("What is the total amount of money you have? ")) goal = total_money * 2 if total_money < 10: print("Sorry but that is too low, please input a higher amount.") Horserestart() elif total_money > 10: print("Your goal is $",goal,"to reach.") bet_amount = int(input("What is the amount you want to bet on? ")) bet_total = total_money - bet_amount print("You will bet $",bet_amount,". You now have $",bet_total," left to bet with. ") print("The race will start in:") Race() # race countdown def Race(): time_sec = 10 while time_sec: mins, secs = divmod(time_sec, 60) timeformat = '{:02d}:{:02d}'.format(mins, secs) print(timeformat, end='\r') time.sleep(1) time_sec -= 1 print("..........THE RACE HAS STARTED..........") Mech_race() # functino of the race (not completed) def Mech_race(): horse1 = "Tyrone" horse2 = "Jamal" horse3 = "Jaquavious" horse4 = "Quandale" horse5 = "Quantavious" horse6 = "Charlie" horses = [horse1, horse2, horse3, horse4, horse5, horse6] random_horse = random.choice(horses) random_horse1 = random.choice(horses) random_horse2 = random.choice(horses) random_horse3 = random.choice(horses) random_horse4 = random.choice(horses) random_horse5 = random.choice(horses) random_horse6 = random.choice(horses) random_horse7 = random.choice(horses) random_horse8 = random.choice(horses) random_horse9 = random.choice(horses) if random_horse is horse1: print(horse1,"has taken the lead!") else: print(random_horse,"has taken the lead!") for positions in range(10): overtakes = "overtakes" trips = "trips" falls_behind = "falls behind" gaining = " is gaining on" takes = "takes" positions = [overtakes, trips, falls_behind, gaining, takes] place = random.choice(positions) if place is overtakes: print(random_horse,"overtakes",random_horse1) elif place is trips: print(random_horse2,"trips",random_horse3) elif place is falls_behind: print(random_horse4,"falls behind",random_horse5) elif place is gaining: print(random_horse6,"gains on",random_horse7) elif place is takes: print(random_horse8,"takes",random_horse9,"position") # introduction to the program/race def Main(): print("Hello and welcome to the Sussy Baka horse race! ") user_name = input("What is your name? ") print("Hello",user_name,"this is when you choose your horse and your bet. ") Horse() Main()
You could paste the code for the Horserestart function anywhere Horserestart() is in the code. def Horse(): print("Horses to bet on: Tyrone, Jamal, Jaquavious, Quandale, Quantavious, and Charlie.") horse_pick = input("What horse do you want to choose? ") if horse_pick == "Tyrone": option = print("You chose Tyrone, your chances of winning are: ") Percent() new_horse = input("Do you wan to change you horse? Type Y or N. ") if new_horse == "Y": Horse() elif new_horse == "N": New() You could also add a counter. horse_restart = 0 def Horserestart(): new_horse = input("Do you wan to change you horse? Type Y or N. ") if new_horse == "Y": horse_restart += 1 Horse() elif new_horse == "N": New() def Horse(): print("Horses to bet on: Tyrone, Jamal, Jaquavious, Quandale, Quantavious, and Charlie.") horse_pick = input("What horse do you want to choose? ") if horse_pick == "Tyrone": option = print("You chose Tyrone, your chances of winning are: ") Percent() if(horse_restart < 1): Horserestart() OR horse_restart = False def Horserestart(): new_horse = input("Do you wan to change you horse? Type Y or N. ") if new_horse == "Y": horse_restart = True Horse() elif new_horse == "N": New() def Horse(): print("Horses to bet on: Tyrone, Jamal, Jaquavious, Quandale, Quantavious, and Charlie.") horse_pick = input("What horse do you want to choose? ") if horse_pick == "Tyrone": option = print("You chose Tyrone, your chances of winning are: ") Percent() if(horse_restart == False): Horserestart()
How can I add ticket variable and discount variable to calculate total trip cost?
# The options for where the user wants to go. options = str(input("Where would you like to go? ")) if options == "Hawaii": print("You have selected: Hawaii") elif options == "hawaii": print("You have selected: Hawaii") elif options == "bahamas": print("You have selected: The Bahamas") elif options == "Bahamas": print("You have selected: The Bahamas") else: print("Avaliable locations are: Hawaii or the Bahamas.") ticket_price = 2300 discount = 0 # The airlines that are available to the user. print("1. Us Air") print("2. Delta") airline = str(input("Which airline would you like to choose? ")) if airline == 1: print("You have selected US Air") elif airline == 2: print("You have selected Delta Airways") else: print("There are no available airlines at this moment") # Here is where how many tickets are needed based on how many people are going on the flight. passengers = int(input("How many people are joining for this flight? ")) if passengers == 1: print("You have selected one passenger.") elif passengers == 2: print("You have selected two passengers.") elif passengers == 3: print("You have selected three passengers.") else: print("Maximum number of passengers for a single order is 3.") # Here is the chance that you or someone is your group is under the age of 18, and can qualify for a 25% discount. discount = str(input("Are you or any passengers under the age of 18? ")) if discount == "Yes": print("Congrats you qualify for a 25% discount!") elif discount == "yes": print("If so how many?") int(input("")) print("Congrats you qualify for a 25% discount!") else: print("Confirmed, no one is under the age of 18") ticket_cost = (ticket_price*discount* 0.25)
After getting all the information, you may compute the total price ticket_cost = passengers * ticket_price Taking into acount the under 18 part : discount = input("Are you or any passengers under the age of 18? ") passengers_under_18 = 0 if discount.lower() == "yes": print("Congrats you qualify for a 25% discount!") passengers_under_18 = int(input("If so how many?")) else: print("Confirmed, no one is under the age of 18") ticket_cost = (passengers - passengers_under_18) * ticket_price + passengers_under_18 * ticket_price * 0.25
Argument of type 'type' is not iterable.How?
money = 0 day = 1 items = [] def gameplay(): global items global money global day energy = 10 work = 0 while True: print("Type 'help' for assistance") play = str(input("-> ")).strip() if play.lower() == "help": print(""" Type : To : Cost: 'Work' Get Money (only once then next day) 5 Energy 'Mall' Buy Stuff 5 Energy 'Items' Check Inventory N/A 'Money' Check Balance Of Money N/A 'Energy' Check Balance Of Energy N/A 'Day' Check your day, day 1 , day 2 etc. N/A 'Done' End Your Day N/A """) elif play.lower() == "work": if work == 1: print("You have already worked!") else: energy -= 5 print("Working......") money += 5 work += 1 print("You now have $%s and %s Energy" % (money, energy)) elif play.lower() == "mall": energy -= 5 while True: print("What do you want to do?") print(""" Type : To: Cost: Coffee Buy Normal Coffee : +2 energy next day $4 Lottery Buy A Lottery Ticket (per day) $10 Money Check Balance Of Money N/A Energy Check Balance Of Energy N/A Items Check Your Inventory N/A Exit Exit the shopping mall N/A """) mall = input("-> ").strip() if mall.lower() == "coffee": if "coffee" in list: print("You have already bought a cup of coffee!") elif money < 4: print("You don't have enough money!") else: print("You bought a coffee") items.append("coffee") print(items) if mall.lower() == "lottery": if "Lottery Ticket" in list: print("You have already bought a ticket! Try again next day!") lot = random.randint(1, 20) jack = random.randint(100, 1000) while True: if money < 10: print("You don't have enough money!") break else: list.append("Lottery Ticket") money -= 10 print("Choose a number between 1 to 20") try: lotg = int(input("-> ")) if lotg == lot: print("Congratulations you have won $%s" % (jack)) money += jack break elif lotg != lot: print("Sorry but you lost! Good luck Next Time") break except ValueError: print("Please Type A Number") elif mall.lower() == "money": print("You currently have $%s" % (money)) elif mall.lower() == "energy": print("You currently have %s" % (energy)) elif mall.lower() == "items": print("These are your following items:") print(items) elif mall.lower() == "exit": print("Exiting mall......") break elif play.lower() == "items": print("These are your following items:") print(items) elif play.lower() == "money": print("You currently have $%s" % (money)) elif play.lower() == "energy": print("You currently have %s" % (energy)) elif play.lower() == "day" : print("Its Day %s " % (day)) elif play.lower() == "done": while True: print("Are You Sure?") sure = str(input("-> ")) if sure.lower() not in ["yes","no"]: print("Please Type Yes Or No ") elif sure.lower() == "yes": print("Going Home For Next Day........") home() elif sure.lower() == "no": print("Okay!") break def noenergy(): print("You don't have enough energy to do that") def home(): print("You are at home..") gameplay() It sometimes shows: Traceback (most recent call last): File "/home/alex/.config/JetBrains/PyCharm2020.1/scratches/scratch_718.py", line 120, in <module> gameplay() File "/home/alex/.config/JetBrains/PyCharm2020.1/scratches/scratch_718.py", line 50, in gameplay if "coffee" in list: TypeError: argument of type 'type' is not iterable when i test it in this order input -> mall input -> coffee The error message should pop up Tried to change the while loop part to a for loop but , still the same and I can't find any answers on a single website Why is this happening? The loop? The list? The input?
list is not a variable containing a list, it's the type (hence the error message) of list objects. It looks like you meant to use the variable items which is a list and forgot or got confused.
fruit machine GSCE challenge
I'm sure you have all heard of the GCSE fruit machine challenge. Well I am having issues with that, you see, when the user spins 3 skulls it doesn't deduct all their credits and when they only spin 2 skulls it doesn't deduct 1 credit. If anyone can help please do. credit = 1 import time t = 1 while True: import random symbols = 'Star' , 'Skull' spin = random.choices(symbols,k=1) spin2 = random.choices(symbols,k=1) spin3 = random.choices(symbols,k=1) ask = input('do you want to spin? ') if ask == 'yes': credit = (credit - 0.2) credit = (round(credit, 2)) print('You now have... ' +str(credit) + ' credit(s).') time.sleep (t) print('** NOW ROLLING **') time.sleep (t) print('You rolled... ' +str(spin) +str(spin2) +str(spin3)) time.sleep (t) if (spin == spin2 == 'Skull' or spin == spin3 == 'Skull' or spin2 == spin3 == 'Skull'): credit = (credit - 1) credit = (round(credit, 2)) print('Uh Oh! you rolled 2 skulls.... you lost 1 credit sorry!') print('You now have a total balance of... ' +str(credit)+ ' credits!') if credit >= 0.2: continue else: print('Sorry! you dont have enough credits.') break elif spin == 'Skull' and spin2 == 'Skull' and spin3 == 'Skull': credit = (credit - credit) print('You rolled 3 Skulls!! You lost all your credits!') break elif spin == spin2 and spin2 == spin3: credit = (credit + 1) print('You won 1 credit!') print('You now have a total balance of... ' +str(credit)+ ' credits!') if credit >= 0.2: continue else: print('Sorry! you dont have enough credits.') break elif spin == spin2 or spin == spin3 or spin2 == spin3: credit = (credit + 0.5) credit = (round(credit, 2)) print('You won 0.5 credits!') print('You now have a total balance of... ' +str(credit)+ ' credits!') if credit >= 0.2: continue else: print('Sorry! you dont have enough credits.') break else: print('Sorry you didnt win anything.') if credit >= 0.2: continue else: print('Sorry! you dont have enough credits.') break elif ask == 'no': print('Your total winnings are.... ' +str(credit)) break else: print('please say yes or no..') continue
The problem is you are comparing list to string where "Skull" is a string and the variable "spin" is a list of one element. To solve this you can turn "spin" to a string using spin = random.choice(symbols) which will make one choice as a string. You seem new to python so I also rewrote your code. You are more than welcome to ask questions about it :) import time import random t = 1 credit = 1.0 while True: symbols = "Star", "Skull" spins = random.choices(symbols, k=3) ask = input("Do you want to spin? ") if ask == "yes": credit -= 0.2 print(f"You now have... {credit} credit(s).") time.sleep(t) print("** NOW ROLLING **") time.sleep(t) print("You rolled... " + " ".join(spins)) time.sleep(t) if sum(spin == "Skull" for spin in spins) == 2: credit -= 1 print("Uh Oh! you rolled 2 skulls.... you lost 1 credit, sorry!") elif sum([spin == "Skull" for spin in spins]) == 3: credit = 0 print("You rolled 3 Skulls!! You lost all your credits!") elif all(spin == spins[0] for spin in spins): credit += 1 print("You won 1 credit!") elif len(set(spins)) != len(spins): credit += 0.5 print("You won 0.5 credits!") else: print("Sorry you didn't win anything.") credit = (round(credit, 2)) print(f"You now have a total balance of... {credit} credits!") if credit >= 0.2: continue else: print("Sorry! You don't have enough credits.") break elif ask == "no": print(f"Your total winnings are.... {credit}") break else: print("Please say yes or no..") continue Good Luck