-
Notifications
You must be signed in to change notification settings - Fork 1
/
project_function_2.py
58 lines (50 loc) · 1.85 KB
/
project_function_2.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
# Define play function
import random
def play():
# user input to get users lucky number
user_chooice = int(input('\nEnter your lucky number between 1 to 10: '))
# condtion to check is user number math with system number or not.
# if mathc user wins if not user loss
system_number = random.randrange(1,10)
# print('\nRand number: ',system_number)
if user_chooice == system_number:
result = """
# --------------------------------
# Choose your lucky number
# --------------------------------
# Your number is {}
# My number is {}
# --------------------------------
# You Won the match!
# --------------------------------
""".format(user_chooice, system_number)
print(result)
# call again show message to show the message and not exit the user forcfully.
show_message()
else:
print('\nYou loose the game try again.')
show_message()
# 1. user ko option show karna hai:
def show_message():
message = """
# --------------------------------
# Let's Start Game
# --------------------------------
# 1. Play
# 2. Exit
# --------------------------------
"""
print(message)
user_input = input('\nEnter your chooice: ')
# print('\nYour luck lucy number is', user_input)
# check user input condition and call related function
if user_input == '1':
play()
elif user_input == '2':
print('\nThanks for playing and you are successfully exit form game.\n')
else:
print('\nYou enter wrong entry try again with only numbers 1 or 2\n')
# again call same function it self form inside same function.
show_message()
# Call show message functiion to show message to user
show_message()