Can i get help i am new to python

Question:
how can i make it print you have won 2 cars if num has = 10 more than once and it adds up the more times that num has = 10

Current behavior:

Desired behavior

Repl link:
https://replit.com/@TrentBaker1/Wheel-of-Fortune#main.py

code snippet

Can you explain this better?

2 Likes

Paraphrased in order to make more sense:

You could do this:

if num == 10:
    print(f'You have won {num} cars!')

Not sure what you mean about multiple times though.

You can also refer to the post mentioned below by @lznmarcos.

1 Like

Hello, TrentBaker1!

You can create a variable to track the number of cars the player wins and add 1 to it everytime the player spins a 10 and then use this variable in your reward message.

You should initialize/reset the car variable at the begining of the code just like the other variables.

import random

task = ""
cash = 0
car = 0
reward = ""

Try to update your if statement for the 10 spin and check if it returns as expected.

  if num == 1:
    print(" you lost it all")
    cash = 0
    reward = ""
    break
  else:
    if num == 10:
      print("you just won a car")
      car += 1
      if car > 1:
          reward = f"you won {car} cars"
      else:
          reward = "you won the car"

Probably there are better ways to acomplish that but I tried to keep it simple.
I hope it helps. Keep up coding.

1 Like

thank you for the help

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.