Kleine Änderung!
print("Willkommen bei Hang Man. 7 Fehler = Game Over !")
run = True
x = ""
h\_u = "\_\_\_\_\_\_"
def next\_try():
global run
global x
global h\_u
while run:
variable = str(input('''
Ihr versuch: '''))
if variable != "p" or "y" or "t" or "h" or "o" or "n":
x += "x "
elif variable == "p" or "y" or "t" or "h" or "o" or "n":
h\_u -= "\_"
h\_u += "\*"
if x == "x x x x x x x":
run = False
print(h\_u)
print(next\_try())
Ich bin gerade dabei Hang Man zu programieren dabei werden allerdings viele Fehler angezeigt ich bitte euch um Hilfe
Hang Man:
print("Wilkommen bei Hang Man. Wenn sie mehr als 7 Fehler haben sind sie raus!")
run= True
x = ""
def next_try():
global x
global run
while run:
try = input('''
Ihr versuch: ''')
if try != "p" or "y" or "t" or "h" or "o" or "n":
x += "x "
if x == "x x x x x x x":
run = False
in dem script sind natürlich zeilenumbrüche, die werden nur nicht dar gestellt
Es ist nicht if if if... sondern if elif ... else. Aber Danke die 2 Klammern haben gefehlt.
Ich habe es noch ein bisschen geendert und es ist das rausgekommen (anderung : int(input(...)).
Script:
one = int(input("1 zahl: "))
two = int(input("2 Zahl: "))
tree = int(input("3 Zahl: "))
four = int(input("4 Zahl: "))
def add():
val = one + two + tree + four
return val
def sub():
val = one - two - tree - four
return val
def multiply():
val = one * two * tree * four
return val
def div():
val = one / two / tree / four
return val
x = int(input('''Was wollen sie rechnen?
+ = 1
- = 2
* = 3
/ = 4
: '''))
if x == 1:
print(multiply)
if x == 2:
print(sub)
if x == 3:
print(multiply)
if x == 4:
print(div)
Also ich habe ein kleines script für einen komischen Taschenrechner geschrieben und der if - if -if -if teil unten wird einfach übersehen.
Ich brauche eure hilfe beim Programmieren ( Phyton). Bitte.
Mein Script:
one = int(input("1 zahl: "))
two = int(input("2 Zahl: "))
tree = int(input("3 Zahl: "))
four = int(input("4 Zahl: "))
def add():
val = one + two + tree + four
return val
def sub():
val = one - two - tree - four
return val
def multiply():
val = one * two * tree * four
return val
def div():
val = one / two / tree / four
return val
x = input('''Was wollen sie rechnen?
+ = 1
- = 2
* = 3
/ = 4
: ''')
if x == 1:
print(multiply)
if x == 2:
print(sub)
if x == 3:
print(multiply)
if x == 4:
print(div)