Correction of this code | SoloLearn: Learn to code for FREE!

0

Correction of this code

https://code.sololearn.com/c2r9uJvOWmY2/?ref=app

10/13/2019 6:27:21 PM

Akash Pawar

32 Answers

New Answer

+7

import random target_num, guess_num = random.randint(1, 10), 0 while target_num != guess_num: guess_num = int(input('Guess a number between 1 and 10 until you get it right : ')) print('Well guessed!')

+3

a = int(input("enter a value between 1 to 9")) if a > 9: print(" well guess") else: print(" guess again")

+2

I tried. Sorry. 😅 Maybe someone else will find the good answer.

+2

there you go. import random target = random.randint(1,10) guess = 0 while guess != target: guess = int(input()) print("found")

+2

https://code.sololearn.com/cp5BXRFnVRAa/?ref=app check this

+1

Try this one, but outside of sololearn code-playground, e.g. in Pydroid3 on Android or Python-IDLE on PC. while True: a = int(input("\nenter a value between 1 to 9: ")) if 0 < a < 10: print("well guess") else: print("wrong guess") if input("\nguess again? [y/n] ").lower()!="y": break print("Game Over!")

+1

Could explain what do you want? I understand that you need to get one number between 1-9. num = input("Enter a number between 1-9: ") try: if 1 <= int(num) <= 9: print("well guess") else: print("guess again") except: print("enter a int number ")

+1

Just try another online python intepreter

+1

Run perfect

+1

Akash great, you can do it

+1

Also there are other methods to do this making a guessing game but i am not going to make something like that any time soon

+1

Re:I want this loop continue if he enters a wrong number this is not possible in sololearn But You can use Do while loop

+1

https://code.sololearn.com/cIDc87yNc1Z9/?ref=app

+1

while True: a=input("Guess a Number: ") try: x=int(a) if 1<=x<=9: print("Correct guess") break else: print("Wrong guess") except: print("Warning:Enter only integers!") #make sure u enter numbers in different lines

+1

0

I want this loop continue if he enters a wrong number

0

Shows error bro

0

He did with random module

0

a = int(input("enter a value between 1 to 9\n")) while 1: if 1< a < 9: print("well guess") break else: a = int(input("guess again\n"))

0

It shows error when i put 10