-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuessinggame.py
More file actions
27 lines (26 loc) · 787 Bytes
/
Guessinggame.py
File metadata and controls
27 lines (26 loc) · 787 Bytes
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
import random
chosen=random.randint(1,100)
Guess=0
Game={}
Players=[]
while(1):
print("Welcome to the random number choosing game.Let's see who wins!")
number=int(input("Enter the number of players: "))
while number!=0:
name=input("Enter the name of Player: ")
Players.append(name)
number=number-1
for i in Players:
Game.update({i:1})
print("Let's begin!")
trial=0
while(trial!=chosen):
for i in Players:
trial=int(input("{}'s guess: ".format(i)))
if trial==chosen:
print("Congratulations! {} won in {} number of guesses!".format(i,Guess+1))
break
else:
Game.update({i:Guess})
Guess=Guess+1
break