@BenjaminSMITH69/

# Cricket Game2

## No description

Files
• main.py
main.py
```1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
```
```def main():
from random import randint
name_name = []
name_score = []
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("Welcome to Ben's Cricket Game!!")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print()
print("1. Play the Game")
print("2. View High Scores")
print()

choice = int(input("Please enter one of the numbers: "))
if choice == 1:
playGame()
elif choice == 2:
highScores()
else:
print("You didn't enter one of the above.")

def playGame():
print ("Let's play cricket")

batting = True
score = 0
while batting:
out = randint (1, 8)
print ("The bowler is running in...")
print ("Pick a number to see if you got any runs.")
ball = int(input("1, 2, 3, 4, 5, 6, 7 or 8? "))
if ball >= 9:
print("That is not between 1 and 8")
print("Game over for the cheater")
break
ball_num = int(ball)
if ball_num == out:
print ("That's Out!!")
print ("Unlucky",user)
print ("Game Over. You scored", score)
hScores = open("highScores.txt", "a")
hScores.write(user)
hScores.write(",")
hScores.write("%d" % score)
hScores.write("\n")
hScores.close()
batting = False
else:
print ("Run's!!")
score = score + randint (1,6)
if score >= 50 and score <= 55:
print ("50 runs!! Well done",user)

if score >= 100 and score <= 105:
print("Well batted!! 100 runs!!")

def highScores():
with open("highScores.txt", "r") as f: