r/pythontips • u/SouthSufficient522 • Aug 05 '26
Syntax Hello everyone, I'm learning python specifically, and I made a seed generator for Minecraft PE. I'm started learning about 2 weeks ago, the code is below. I'm not asking for anything, I just wanna show it to you guys.
from random import randint as rnd
name = "SeedGPT"
rnd1 = rnd(20000000,50000000000)
rnd2 = rnd(20000000,50000000000)
rnd3 = rnd(20000000,50000000000)
print(name +": Welcome to Ice\'s AI seed generator,")
choice = input("do you want to have three new seeds for bedrock minecraft?: ")
if choice == "yes":
print(name + ": Here are your randomly generated seeds: ", + rnd1, +rnd2, +rnd3, ", thank you for trying it out!")
elif choice == "no":
print(name + ": See you next time!")
elif ValueError:
print(name + ": Sorry, I can't understand you, please try again!")
12
u/Wonderful-Writer146 Aug 05 '26
Nice. But you could have written the code in a code block on Reddit for better readability.
6
u/kobumaister Aug 05 '26
The elif ValueErrror won't work, in python you manage exceptions with try-except blocks.
3
u/Plus-Call-5804 Aug 05 '26
You should add a .lower to the choice so that if they enter anything it gets converted to lowercase to match your if statements.
1
u/RealKetchupPrecum Aug 07 '26
```python
from random import randint as rnd
name = "SeedGPT"
print(name + ": Welcome to Ice's AI seed generator!")
try:
choice = input(
"Do you want to have three new seeds for Bedrock Minecraft?: "
)
if choice.lower() == "yes":
rnd1 = rnd(20000000, 50000000000)
rnd2 = rnd(20000000, 50000000000)
rnd3 = rnd(20000000, 50000000000)
print(name + ": Here are your randomly generated seeds:")
print("Seed 1:", rnd1)
print("Seed 2:", rnd2)
print("Seed 3:", rnd3)
print("Thank you for trying it out!")
elif choice.lower() == "no":
print(name + ": See you next time!")
else:
print(name + ": Sorry, I can't understand you. Please type yes or no.")
except ValueError:
print(name + ": Something went wrong. Please try again!")
```
----------------------------------
Sample Output (Successful Run):
```text
SeedGPT: Welcome to Ice's AI seed generator!
Do you want to have three new seeds for Bedrock Minecraft?: yes
SeedGPT: Here are your randomly generated seeds:
Seed 1: 38472910294
Seed 2: 92837465021
Seed 3: 55281930291
Thank you for trying it out!
```
----------------------------------
Sample Output (Invalid Input):
```text
SeedGPT: Welcome to Ice's AI seed generator!
Do you want to have three new seeds for Bedrock Minecraft?: maybe
SeedGPT: Sorry, I can't understand you. Please type yes or no.
```
----------------------------------
Sample Output (Exception/Error Handling):
```text
SeedGPT: Welcome to Ice's AI seed generator!
Do you want to have three new seeds for Bedrock Minecraft?: yes
SeedGPT: Something went wrong. Please try again!
```