Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- My code(corrected version):
- ```py
- import random
- def dice():
- options = int(input("How many options will this dice have?"))
- ordinal = ["first", "second", "third", "fourth", "fifth", "sixth", "eighth", "nineth", "tenth"][:options]
- optionsum = []
- for i in ordinal:
- optionsum.append(input(f"What is your {i} option?"))
- choice = random.choice(optionsum)
- print(f"The result is {choice}")```
- What he suggested:
- ```py
- def number_to_word(n):
- return ["first", "second", "third", "fourth", "fifth", "sixth", "eighth", "nineth", "tenth"][n]
- def Dice():
- optionssum = int(input("How many options will this dice have?"))
- answers = [input(f"What is your {o} option?") for o in range(optionssum)]
- for index, a in enumerate(answers):
- print(f"{number_to_word(index)}: {a}")
- Dice()```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement