#πŸ”’ help me with my awesome guessthenumber g ame

90 messages Β· Page 1 of 1 (latest)

arctic warren
#

i wanna add an extra string when there is only 1 attempt left

def guess_the_number():

    minimum_number = 1
    maximum_number = 100

    print("Welcome to this super duper funny and professionaly coded Guess The Number game! :D\n")
    print(f"choose a super duper cool number between {minimum_number} and {maximum_number}\n")

    secret_number = random.randint(minimum_number,maximum_number)
  

    attempts = 0
    max_attempts = 6
    while attempts < max_attempts:
        try:
                
            chosen_number = int(input(f"Choose a random number between {minimum_number} and {maximum_number}: \n"))

            if chosen_number < 1 or chosen_number > 100:
                print("this isn't a normal number u numbnut. Are you like stupid or something... try again.\n")
                continue
            
            attempts += 1

            if chosen_number < secret_number:
                print("choose a higher number you knucklehead!")
                print(f"you wont make it because you suck, but still... you have {max_attempts - attempts} attempts left.\n")
            elif chosen_number > secret_number:
                print("its a lower number you goofball!")
                print(f"you wont make it because you suck, but still... you have {max_attempts - attempts} attempts left.\n")
            elif  . . .. . . .anitamaxwin
                priint u suck
            else:
                if attempts == (max_attempts - 1):
                    print(f"wow you are so fcking smart you guessed {secret_number} in {attempts} tries and had {6 - attempts} more try\n")
                else:
                    print(f"wow you are so fcking smart you guessed {secret_number} in {attempts} tries and had {6 - attempts} more tries\n")
                break  
        except ValueError:
            print("are you stupid? is that a number?\n")     

    else: 
        print(f"\nyou fcking suck the number was {secret_number}.\n")
guess_the_number()
vernal summitBOT
#

@arctic warren

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

lime falcon
#

wdym where rhere is one attempt left?

arctic warren
#

well rn

lime falcon
#

if attempts - max_attempts = 1 print("1 left my g")

arctic warren
#

u have 6 attemps total

#

and it shows that

#

but i want when there is liike 1 more another string with like "you will never make u u suck"

#

u know

#

where do i put that if?

#

thats what i was struggling with

lime falcon
#

u add an if inside the whole loop on top

if (attempts-max_attemts == 1):
  print("1 attempt left:)
arctic warren
#

not here right

lime falcon
#

max_attempts

arctic warren
#

oops

#

the place is good?

lime falcon
#

or no emm do max attempts - attempts

#

cuz u get - everytime

arctic warren
#

like this?

#

thx boss

lime falcon
#

ye

arctic warren
#

alarm @lime falcon its stuck on the last try now

#

everytime

lime falcon
#

do u mean it loops?

arctic warren
#

after the print?

#

ye i keeps saying i have 1 attempt

#

nvm

#

im dumb

lime falcon
#

huh

arctic warren
#

it did earlier not anymore

lime falcon
#

lol

arctic warren
#

how would i do it so it doesnt print this when there is 0 attempts left

 if chosen_number < secret_number:
                print("\nchoose a higher number you knucklehead!")
                print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")
            elif chosen_number > secret_number:
                print("its a lower number you goofball!")
                print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")
#

since u cant really guess again not really a point in saying that except for the last string

lime falcon
#

hhahahahahah

#

say what

arctic warren
#

well everytime after u guess a number it says choose ahigher number you knucklehead and keep trying etc

#

but after the last attempt its kinda pointless saying that no

lime falcon
#

choose a higher number right?

#

you could do emm

arctic warren
#

do i do while loop untill the last try maybe?

lime falcon
#

u could do smth like

if attempts!=0:
  print("Choose higher")
#

but idk what variable u have

arctic warren
#

no i mean like

#

that i dont print those things after the final attempt

#

i do now bcs its in the loop

lime falcon
#

those u mean all of them

arctic warren
#

the top 2 strings

#

and only after the final attempt

lime falcon
#
           if (chosen_number < secret_number) & (max_attempts-attempts!=0):
                print("\nchoose a higher number you knucklehead!")
                print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")
            elif chosen_number > secret_number:
                print("its a lower number you goofball!")
                print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")```
#

this maybe

arctic warren
#

i chose 55 but i was 63

#

and i said i was correct

lime falcon
#

hahahahahah

#

wait

arctic warren
#

after doing ur change

#

god knows why

lime falcon
#

try this one ;D

#
            if (chosen_number < secret_number) :
               if max_attempts-attempts!=0:
                  print("\nchoose a higher number you knucklehead!")
                  print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")
            elif chosen_number > secret_number:
                print("its a lower number you goofball!")
                print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")```
arctic warren
#

still gives the strings

lime falcon
#

send me the code :v

#

i try here

lime falcon
#

elif . . .. . . .anitamaxwin
priint u suck

arctic warren
#

huh

#

u gotta remove that

lime falcon
#

thats whats in ur code

arctic warren
#

ye i see oops

#

just delete that hahahaa

#

that was like a thinking out loud

#

nvm its the wrong one oops

#
def guess_the_number():

    minimum_number = 1
    maximum_number = 100

    print("Welcome to this super duper funny and professionaly coded Guess The Number game! :D\n")
    print(f"choose a super duper cool number between {minimum_number} and {maximum_number}\n")

    secret_number = random.randint(minimum_number,maximum_number)
  

    attempts = 0
    max_attempts = 6
    while attempts < max_attempts:
        try:
            if max_attempts - attempts == 1:
                print("you will never get the secret number lol hihi (im so silly)")  

            chosen_number = int(input(f"Choose a random number between {minimum_number} and {maximum_number}: \n"))

            if chosen_number < 1 or chosen_number > 100:
                print("this isn't a normal number u numbnut. Are you like stupid or something... try again.\n")
                continue
            
            attempts += 1

            if chosen_number < secret_number:
                print("\nchoose a higher number you knucklehead!")
                print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")
            elif chosen_number > secret_number:
                print("its a lower number you goofball!")
                print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")
            else:
                if attempts == (max_attempts - 1):
                    print(f"wow you are so fcking smart you guessed {secret_number} in {attempts} tries while having {6 - attempts} more try\n")
                else:
                    print(f"wow you are so fcking smart you guessed {secret_number} in {attempts} tries while having {6 - attempts} more tries\n")
                break  
        except ValueError:
            print("are you stupid? is that a number?\n")     

    else: 
        print(f"\nyou fcking suck.. A for effort.. anywhos the number was {secret_number}.\n")
guess_the_number()
#

onyl added the first if

lime falcon
#
            if chosen_number < secret_number:
                if max_attempts-attempts!=0:
                    print("choose a higher number you knucklehead!")
                    print(f"you wont make it because you suck, but still... you have {max_attempts - attempts} attempts left.\n")
            elif chosen_number > secret_number:
                if max_attempts-attempts!=0:
                    print("its a lower number you goofball!")
                    print(f"you wont make it because you suck, but still... you have {max_attempts - attempts} attempts left.\n")```
#

bum

arctic warren
#

boem

#

thanks boss

lime falcon
#

🫑

arctic warren
#

magic

#

now i just gotta parsing what u did

arctic warren
# lime falcon ```py if chosen_number < secret_number: if max_attem...
if chosen_number < secret_number:
                print("\nchoose a higher number you knucklehead!")
                print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")
            elif chosen_number > secret_number:
                print("its a lower number you goofball!")
                print(f"keep trying buddy, you have {max_attempts - attempts} attempts left.")

u made this into that right

lime falcon
#

yes

arctic warren
#

alrighty thanky

#

so it does it all the same but only if there is an amount off attempts left

#

if non (its !=0) so its goes further

#

u a wizard

lime falcon
#

🀣

vernal summitBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.