mit try und except & while
This commit is contained in:
parent
ad996cff8f
commit
8e09d01f97
21
main.py
21
main.py
@ -1,8 +1,21 @@
|
||||
#!/usr/bin/python3
|
||||
import random
|
||||
cube = 'Würfel-Generator\nZum Würfeln die 1 Drücken.'
|
||||
print(cube.center(54))
|
||||
def cube():
|
||||
while True:
|
||||
try:
|
||||
entry = int(input('1 drücken zum Würfeln.\n'))
|
||||
#entry = int(entry)
|
||||
return entry
|
||||
break
|
||||
|
||||
cube = 'Würfel-Generator\nZum Würfeln die 1 Drücken zum beenden die 2.'
|
||||
print(cube.center(88))
|
||||
except ValueError:
|
||||
print('Ups! Keine Zahl eingegeben. Bitte nochmal versuchen.\n')
|
||||
|
||||
|
||||
print(random.randint(1,6))
|
||||
cube()
|
||||
while cube() == 1:
|
||||
print(random.randint(1, 6))
|
||||
#print('1 drücken um erneut zu würfeln')
|
||||
else:
|
||||
print('alles andere')
|
||||
|
Loading…
x
Reference in New Issue
Block a user