Advertisement
Guest User

Untitled

a guest
Dec 11th, 2023
1,488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. My code(corrected version):
  2. ```py
  3. import random
  4. def dice():
  5. options = int(input("How many options will this dice have?"))
  6. ordinal = ["first", "second", "third", "fourth", "fifth", "sixth", "eighth", "nineth", "tenth"][:options]
  7. optionsum = []
  8.  
  9. for i in ordinal:
  10. optionsum.append(input(f"What is your {i} option?"))
  11.  
  12. choice = random.choice(optionsum)
  13. print(f"The result is {choice}")```
  14.  
  15. What he suggested:
  16. ```py
  17. def number_to_word(n):
  18. return ["first", "second", "third", "fourth", "fifth", "sixth", "eighth", "nineth", "tenth"][n]
  19. def Dice():
  20. optionssum = int(input("How many options will this dice have?"))
  21.  
  22. answers = [input(f"What is your {o} option?") for o in range(optionssum)]
  23.  
  24. for index, a in enumerate(answers):
  25. print(f"{number_to_word(index)}: {a}")
  26.  
  27.  
  28. Dice()```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement