Is my first post here and well, im very new with python (just aroun 10 days). I did the famous "Guess my number" game. (Python pick up a number and user must guess it).
All right, i have not problems with this. But now im trying in the other way.
I mean, user pick up a number between 1-20 (for example), if the number isnt between 1-20, python warns about this.
Python have 5 tries to guess the number, and user should tell: first, if the number given by python is the pick up number or not. If user says "No" but is Yes, python "Kick the user for cheater", otherwise, if user say Yes -Always- (ever if isnt the user´s number) python wins.
So, if user says "No" and really is No, python ask "lower or higher?".
Im trying to do this loop with little i know about python. Here is my code. (Im stuck):
# Guess My Number Inverted # This time, user pick up the number # and python must guess it. number = int(input("pick a number between 1 and 100: ")) while number < 1 or number > 100: print("I told you a number between 1 - 100 bitch!!") print("Try again and this time dont fuck with me.") number = int(input("Escribe un número entre el 1 y el 100: ")) import random tries = 0 guess = 0 input("Ok... Let´s finish with this shit.") while tries < 6: guess = random.randint(1, 20) print("your number is", guess, "?") tries +=1 response = input("\nYes/No: ") if response == "Yes": print("Perfect! i won!!") print("Get the fuck off of here, loser") input("Please, press -Enter- To get the fuck off of here, loser.") break elif response == "No": if guess == number: print("You fool!!! This is your number!!!!") print("Get the fuck off of here and comeback when you can play fair.") input("Press -Enter- to exit, cheater.") break elif guess != number: clue = input("Damn you!! lower or higher??: ") if clue == "lower": guess2 = random.randint(1, guess ) tries +=1 print("Your number is ", guess2, "?") elif clue == "higher": guess2 = random.randint(guess, 20) tries +=1 print("Your number is ", guess2, "?") if tries == 6 and guess2 != number: print("oooooh what´s wrong? i though i was the best...") print("Ok, you won, but you´ll not so lucky the next time.") input("press -Enter- to exit, winner.")
I think that my problem is with "guess2" and the refresh between lower and higher values of guess.
i dont know how do a loop and refresh the "guess2" between lower and higher :/.
If you could give me some clue, i thank you so much.
Thanks guys! ;)