Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def insert_word():
- print("Input Sentence:")
- word = input()
- word_list = []
- for letter in word:
- word_list.append(letter)
- return word_list
- def word_underscore_converter(word_list):
- underscored_list = []
- upper_string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- for letter in word_list:
- if letter in upper_string:
- underscored_list.append("_")
- elif letter in " ":
- underscored_list.append(" ")
- return underscored_list
- def underscore_num_checker(word_list):
- counter = 0
- for letter in word_list:
- if letter == '_':
- counter += 1
- return counter
- def hangman_game(word_list, underscored_word, underscored_num):
- is_word_incomplete = True
- underscored_change = 0
- while is_word_incomplete:
- print("Input letter:")
- letter = input()
- counter = 0
- for i in word_list:
- if i == letter:
- underscored_word[counter] = letter
- underscored_change += 1
- print(underscored_word)
- counter += 1
- elif i != letter:
- counter += 1
- if underscored_num == underscored_change:
- print("Sentence Completed!")
- is_word_incomplete = False
- print("***THIS GAME IS PLAYED IN ALL UPPER CASE LETTERS***")
- word_listed = insert_word()
- word_underscored = word_underscore_converter(word_listed)
- underscore_count = underscore_num_checker(word_underscored)
- print("word_listed is: {}".format(word_listed))
- print("word_underscored is: {}".format(word_underscored))
- print("This word has {} underscores".format(underscore_count))
- hangman_game(word_listed, word_underscored, underscore_count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement