IMustRemainUnknown

ML Name Game

Dec 18th, 2023 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.74 KB | Source Code | 0 0
  1. from random import choice
  2.  
  3.  
  4. def print_list(my_list, ctr):
  5.     for idx, item in enumerate(my_list, 1):
  6.         print(f"{item} ", end="")
  7.  
  8.         if idx % ctr == 0:
  9.             print()
  10.  
  11.  
  12. def welcome_message(count):
  13.     print(f"""
  14. --------------[ Welcome to Mobile Legends! ]--------------
  15. \tThis game is about Mobile Legends hero names. We will
  16. give a clue about the hero's first letter and you will
  17. guess the hero's name. Capitalization is not strict but
  18. make sure about the spelling.  Currently, there's {count}
  19. heroes on my list.
  20. """)
  21.  
  22.  
  23. hero_list = ["Granger", "Gusion", "Fanny", "Alucard", "Nana", "Gatotkaca", "Bane", "Moskov", "Carmilla", "Freya",
  24.            "Miya", "Balmond", "Saber", "Alice", "Tigreal", "Karina", "Akai", "Franco", "Bruno", "Clint",
  25.            "Rafaela", "Eudora", "Zilong", "Layla", "Minotaur", "Lolita", "Hayabusa", "Gord", "Natalia", "Kagura",
  26.            "Chou", "Sun", "Alpha", "Ruby", "Yi Sun-shin", "Johnson", "Diggie", "Estes", "Hilda", "Aurora",
  27.            "Lapu-Lapu", "Vexana", "Roger", "Karrie", "Harley", "Irithel", "Grock", "Argus", "Odette", "Lancelot",
  28.            "Hylos", "Zhask", "Helcurt", "Pharsa", "Lesley", "Jawhead", "Angela", "Valir", "Martis", "Uranus",
  29.            "Hanabi", "Chang'e", "Kaja", "Selena", "Aldous", "Claude", "Leomord", "Lunox", "Hanzo", "Belerick",
  30.            "Kimmy", "Thamuz", "Harith", "Minsitthar", "Kadita", "Faramis", "Badang", "Khufra", "Guinevere",
  31.            "Esmeralda", "Terizla", "X.Borg", "Ling", "Dyrroth", "Lylia", "Baxia", "Masha", "Wanwan", "Silvanna",
  32.            "Cecilion", "Atlas", "Popol and Kupa", "Yu Zhong", "Luo Yi", "Benedetta", "Khaleed", "Barats", "Brody",
  33.            "Yve", "Mathilda", "Paquito", "Gloo", "Beatrix", "Phoveus", "Natan", "Aulus", "Aamon", "Valentina",
  34.            "Edith", "Floryn", "Yin", "Melissa", "Xavier", "Julian", "Fredrinn", "Joy", "Novaria", "Arlott", "Ixia",
  35.            "Nolan", "Vale", "Cyclops"]
  36.  
  37.  
  38. hero_counts = len(hero_list)
  39. welcome_message(hero_counts)
  40.  
  41. score = 0
  42. hero_list = [hero.capitalize() for hero in hero_list]
  43. already_guessed = []
  44.  
  45. while True:
  46.     clue = choice(hero_list)[0]
  47.     guess = input(f"Type hero's name starting from letter {clue}: ").capitalize()
  48.  
  49.     if guess in hero_list and guess[0] == clue:
  50.         hero_list.remove(guess)
  51.         score += 1
  52.         print(f"You got it right!\U0001F4AA\nScore: {score}\n")
  53.         already_guessed.append(guess)
  54.  
  55.     else:
  56.         if guess in already_guessed:
  57.             print(f"\nYou already guessed {guess}.")
  58.  
  59.         print(f"Game over\U0001F97A\nYour final score is {score}\n")
  60.  
  61.         mylist = [x for x in hero_list if x[0] == clue]  # filter by letter
  62.  
  63.         print(f"Possible answer(s): ")
  64.  
  65.         print_list(mylist, 5)
  66.         print()
  67.         break
  68.  
Add Comment
Please, Sign In to add comment