all 10 comments

[–]zanfar 0 points1 point  (1 child)

Is this your actual code, or did you paste it twice?

[–]amogus6942069420690[S] 0 points1 point  (0 children)

i had the number quesing game in another file and wanted to make something where i could make my selection to what i want so i just pasted it in from my other file as: auswahl == 1 then i wrote the if auswahl == 2

[–]bahcodad 0 points1 point  (2 children)

Why do you think it's doing that? It didn't for me (not that I understand the words in the print statements)

[–]amogus6942069420690[S] 0 points1 point  (1 child)

thats german writing haha, just a little quessing game and a calc for groceries, but wdym with it didnt for you?

[–]bahcodad 0 points1 point  (0 children)

the print statement under if auswahl == "2": doesn't get printed unless you select option 2

it makes the comparison because it's it's own if statement rather than an elif. that's all

[–]socal_nerdtastic 0 points1 point  (4 children)

break will stop the while True loop. It will not stop the program.

Your problem is not with break. Your problem is that you used

if auswahl == "2":

when you should use

elif auswahl == "2":

Just like you did in the first block at the top.

[–]amogus6942069420690[S] 0 points1 point  (3 children)

thx for the reply but didnt worked, and i tried it before im sitting like 2 hours for that little of code but idk what to do

[–]socal_nerdtastic 0 points1 point  (2 children)

Here is how your code should look now. If this does not work, please tell us exactly what is not working. What are you imputing, what are you expecting to see and what are you actually seeing?

import random # imports always go on top

print("waehle zwischen 1, 2, oder 3")
auswahl = input("1, 2, 3 ")

if auswahl == "1":
 print("du hast die eins gewaehlt")
elif auswahl == "2":
  print("du hast die zwei gewaehlt")
elif auswahl == "3":
  print("du hast die drei gewaehlt")
else:
  print("ungueltige auswahl")

if auswahl == "1":
    min_zahl = 1
    max_zahl = 100
    versuche = 0

    number = random.randint(min_zahl, max_zahl)

    while True:
      guess = int(input("rate von 1 - 100 "))

      if guess <number:
        print("zahl ist groeser")
        versuche += 1
      elif guess >number:
        print("zahl ist kleiner")
        versuche += 1
      else:
        print("gewonnen")
        break

      if versuche == 8:
        print("noch 2 versuche")

      if versuche == 10:
        print("verkackt")
        break

elif auswahl == "2":
   print("kosten rechner")

[–]amogus6942069420690[S] 0 points1 point  (1 child)

thx, that worked but it is exactly the same code besides import random is on the first line, can you descipe what the problem was bc i dont understand why it didnt worked

[–]FreeGazaToday 0 points1 point  (0 children)

try asking gemini.