I just started with python. I tried to write a small code for guessing a number. I wondered if we can get out of the function only, not the whole program.
can somebody help me out?(ignore if any other errors)
Code:
def user_guess(num): if(num==rand_num): print "hurrey! you guessed it right.\n" another_try=raw_input("would you like to guess another number??\n") if(another_try == "y" or another_try == "yes"): num = int(input("Guess the number!\n")) return num else: print "okay! have a good day!" sys.exit() elif(num>rand_num): print "your guessed number is greater than the actual number,,\n" guess_again=raw_input("would you like to guess the same number again??\n") if(guess_again == "y" or guess_again == "yes"): num=int(input("guess the number")) user_guess(num) else: #here i want to get out of the function only,I want the other part of the program to run elif(num<rand_num): print "your guessed number is lesser than the actual number,,\n" else:
Comment