+5

# Is my code right?

The programme has to generate a random number which the user has to guess, if the guess is +-5 away from the actual number they will be alerted ”wrong but close” otherwise ”wrong” if the guess is above 100 or below 0 or 1 they will be alerted ”u can only choose between 1-100” https://code.sololearn.com/c0xXLO2pBNTA/?ref=app

1/26/2022 2:29:22 AM

Lenoname

+7

I updated your code as you expected. If you want to ask anything related to this, feel free to ask. https://code.sololearn.com/cgTZ9DmeVpbx/?ref=app

+3

To avoid negative values. I mean if n = 50; guess = 60, it gives -10 for (n - guess) which is less than 5 and same goes to the next condition.

+2

Great code Simba! Since 1-100 is a very big set of possible answers it is quite difficult to get the right answer in the first try. Hence I added a loop to it, so that you can keep guessing until you land on the right answer. Here it is: https://code.sololearn.com/cN63K28QlkUa Feel free to ask any questions related to this.

+1

Simba whats elif 0 <? Not enough with n-guess<=5 or guess-n<=5?

0

Tejas Mestry i ran the code and it works but at the end it says something about line 19,what is that?