Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with my code
#1
1 import random
2
3
4 dice1 = random.randint(1,6)
5 dice2 = random.randint(1,6)
6 dice3 = random.randint(1,6)
7 dice4 = random.randint(1,6)
8
9
10 choise = input ("Welcome to my game! Wana play? yes/no")
11 if choise.lower() == "yes":
12 print ("-----------------------------------------")
13 elif choise != "yes":
14 print ("-----------------------------------------")
15 print ("Okay, goodbye.")
16 exit()
17
18
19 if dice1 == dice2:
20 print ("Unlucky, you scored 0.")
21 elif dice1 != dice2:
22 print ("You rolled a",dice1,"and a",dice2,"that makes",dice1 + dice2,)
23 choise2 = input ("Wana have one more go? yes/no")
24
25
26 if choise2.lower() == "yes":
27 print ("You rolled a",dice3,"and a",dice4,"that makes",dice3 + dice4,)
28 print ("All together that makes",dice1 + dice2 + dice3 +dice4,)
29 elif choise2 != "yes":
30 print ("Okay, goodbye.")



On line 16 I want to be able to end the program if they say no (so it doesn't carry on) without actually having to do exit(). What is the proper way I should do it?
Reply


Messages In This Thread
I need help with my code - by Dynamix123 - Jun-20-2018, 12:59 PM
RE: I need help with my code - by buran - Jun-20-2018, 01:01 PM
RE: I need help with my code - by Nwb - Jun-20-2018, 01:56 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020