Question: Why are the letters printing out vertically? What should i do?
**Repl link: https://replit.com/@QBrd1/Hangman **
import random, time, os
ListofCategories=["Animals", "Landmark", "Sport", "Food"]
ListofAnimals=["Koala","Wombat","Emu", "Dingo","Kangaroo","Quokka", "Tasmanian Devil", "Redback Spider", "Eastern Brown Snake", "Great white shark"]
ListofLandmarks=["Great Barrier Reef","Uluru","Sydney Harbour Bridge","Sydney Opera House","Yarra Valley", "Bondi Beach","Royal Botanic Gardens","Dandenong Ranges","Barossa Valley", "Kakadu National Park"]
ListofSports=["Basketball", "Rugby League", "Football", "Cricket", "Netball","Swimming","Cycling", "Tennis", "Surfing", "Golf"]
ListofFood=["Vegemite Toast","Meat Pies", "Tim Tams", "Fairy Bread", "Fish & Chips", "Chicken Parmigiana", "Pavlova", "Lamingtons", "Sausage Roll", "Pods"]
letterPicked=[]
def game():
lives = 7
while True:
letter=input("\nChoose a letter: ").lower()
if letter in letterPicked:
print("You've given that before. Give another one: ")
continue
letterPicked.append(letter)
if letter in word:
print("You've uncovered a letter")
else:
print("Letter not found in there")
lives -= 1
allLetters = True
print()
for i in word:
if i in letterPicked:
print(i, end="")
else:
print("_", end="")
allLetters = False
print()
if allLetters:
print(f"You've won with {lives} left. Well done!")
break #should ask user to go again
if lives <=0:
print(f"You ran out of lives! The answer is {word}")
break #should ask user to go again
else:
print(f"{lives} lives left")
while True:
time.sleep(1)
#os.system("clear")
category=input("""Which of Australian categories do you want to play?
Press 1 for Animals
Press 2 for Landmarks
Press 3 for Sports
Press 4 for Food\n >>> """)
if category=="1":
print(f"You're playing the Australian Iconic {ListofCategories[0]}! Lets play!")
word=random.choice(ListofAnimals)
game()
elif category=="2":
print(f"You're playing the Australian Iconic {ListofCategories[1]}! Lets play!")
word=random.choice(ListofLandmarks)
game()
elif category=="3":
print(f"You're playing the Australian Iconic {ListofCategories[2]}! Lets play!")
word=random.choice(ListofSports)
game()
elif category=="4":
print(f"You're playing the Australian Iconic {ListofCategories[3]}! Lets play!")
word=random.choice(ListofFood)
game()
else:
print(f"Category {category} not found. Enter a valid selection")
continue
game()