mit try und except & while
This commit is contained in:
parent
ad996cff8f
commit
8e09d01f97
19
main.py
19
main.py
@ -1,8 +1,21 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import random
|
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.'
|
except ValueError:
|
||||||
print(cube.center(88))
|
print('Ups! Keine Zahl eingegeben. Bitte nochmal versuchen.\n')
|
||||||
|
|
||||||
|
|
||||||
|
cube()
|
||||||
|
while cube() == 1:
|
||||||
print(random.randint(1, 6))
|
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