-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
32 lines (22 loc) · 986 Bytes
/
game.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
import re
import random
def __main__():
artist_list = open("artists.txt").readlines()
album_list = open("album_names.txt").readlines()
score = 0;
print("Hello! Welcome to a guessing game! In this game, you'll be given the name of an album and you'll have to guess the artist.\n")
size = (int(input("How many questions would you like to have? The maximum is 60. ")))
#generate a list of numbers from 0 to 59, inclusive
numbers = list(range(0, 60))
#create a list of of the user-given size, containing non-repeating numbers from 0 to 59, inclusive
k = random.sample(numbers, size)
for i in range(0,len(k)):
print(album_list[k[i]])
user_answer = input("Whose album is this?\n")
if (user_answer.lower() == (artist_list[k[i]].lower()).replace("\n", "")):
print("Correct!")
score = score + 1
else:
print("The artist of %s is %s" % (album_list[k[i]].replace("\n",""), artist_list[k[i]]))
print("You got %d out of %d correct!" % (score, size))
__main__()