From db940b9423f0620a8f03e4e52b75bdbdc427b4c9 Mon Sep 17 00:00:00 2001 From: NayanPrakash11 <69430088+NayanPrakash11@users.noreply.github.com> Date: Thu, 1 Oct 2020 01:00:54 +0530 Subject: [PATCH] Add files via upload --- guessgame.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 guessgame.py diff --git a/guessgame.py b/guessgame.py new file mode 100644 index 0000000..d8ee00b --- /dev/null +++ b/guessgame.py @@ -0,0 +1,22 @@ +import random +highest = 10 +answer = random.randint(1,highest) +print(answer) +print('please guess a number from 1 and {}:'.format(highest)) +guess = int(input()) +if guess > answer: + print('please guess lower') + guess = int(input()) + if guess == answer: + print('you won on 2nd attempt') + else: + print('sorry, incorrect guess') +elif guess < answer: + print('please guess higher') + guess = int(input()) + if guess == answer: + print('you won on 3rd attempt') + else: + print('sorry,incorrect guess') +else: + print('wow you nailed it on the first time')