Python game hangman
Build a list of countries L and program which is going to simulates game hangman.
from random import choice L = ['Holland', 'Croatia', 'Afghanistan', 'Ireland', 'Italy', 'Hungary'] country = choice(L) ending = list(country) help_1 = '' for i in range(len(country)): help_1 = help_1 + '-' print(help_1) help_1 = list(help_1) guess = '' K = [] while ending != help_1: guess = input('Enter a letter!') if guess in country: K = list(country) for i in range(len(K)): if K[i] == guess: t = i help_1[t] = guess help_1 = ''.join(help_1) print(help_1) help_1 = list(help_1) else: print('You missed a letter! More luck next time!') break else: print('Exelent!!! You guessed the country!')
-------
Enter a letter! a
----a--
Enter a letter! H
You missed a letter! More luck next time!
Коментари
Постави коментар