Kann mir jemand mit meinem Hangman-Code für eine Schulaufgabe helfen? [geschlossen]Python

Python-Programme
Anonymous
 Kann mir jemand mit meinem Hangman-Code für eine Schulaufgabe helfen? [geschlossen]

Post by Anonymous »

Ich versuche, ein Galgenmännchen-Spiel in Python zu programmieren und weiß einfach nicht, wie ich es zum Laufen bringen soll. Und ich möchte den Code nicht nachschlagen und kopieren, und ich möchte auch nicht, dass jemand das für mich erledigt. Mein Hauptproblem sind die Schleifen. Ich kann nicht herausfinden, wie ich die Ausgabe der vorherigen Iteration der Schleife beibehalten kann, und ich kann nicht herausfinden, wie ich den Henker dazu bringen kann, zur nächsten Stufe zu gelangen. Das ist so ärgerlich, ich komme mir wie ein Idiot vor. Kann mir jemand helfen?

Code: Select all

def get_hangman_stage(remaining_attempts):
stages = [
r"""
_______
|     |
|
|
|
__|__
""",
r"""
_______
|     |
0     |
|
|
__|__
""",
r"""
_______
|     |
0     |
|     |
|
__|__
""",
r"""
_______
|     |
0     |
|     |
/      |
__|__
""",
r"""
_______
|     |
0     |
|     |
/ \    |
__|__
""",
r"""
_______
|     |
0     |
-|     |
/ \    |
__|__
""",
r"""
_______
|     |
0     |
-|-    |
/ \    |
__|__
""",
r"""
_______
|     |
0     |
--|-    |
/ \    |
__|__
""",
r"""
_______
|     |
O     |
--|--   |
/ \    |
__|__
"""
]
print(stages[stage])

import random

words = ["computer", "pineapple", "table", "school", "walking"]
random.shuffle(words)
word = words[1]

stage = 0

noc = 0
for char in word:
if char.isalpha:
noc += 1

get_hangman_stage(remaining_attempts=+1)

print(noc,"digits")

count = 0

guesses = []

while count < noc:
guess = input("Guess a letter")
guesscount = word.count(guess)
if stage == 8:
get_hangman_stage(remaining_attempts=+1)
break
else:
if guess in word:
print(guesscount,guess)
count =+ 1
get_hangman_stage(remaining_attempts=+1)
else:
print("no",guess)
stage =+ 1
get_hangman_stage(remaining_attempts=+1)
continue

while True:
if stage == 8:
print("Game over")
break
else:
fullguess = input("Guess the word")
if fullguess == word:
print("You Win!")
else:
stage =+1
if not stage == 8:
print("Try again")
continue

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post