Ch 35 random number and DRY function

 #random number and DRY fucnction use

#the impprt random is change number always you win

#the function genrate random number

import random

winning_number=random.randint(1,100)

number=int(input("guess a number between 1 to 100"))

guess=1

game_over=False # remmenber_ this to run the program

while not game_over:

if number==winning_number:

print(f"you win,you took {guess} times")

game_over=True

else:

if number<winning_number:

print("too low")

else:

print("too high")

guess+=1

number=int(input("guess again"))# using DRY funtion to short the program line

Comments