r/learnpython • u/SavingsOdd2766 • 7h ago
My first complete comand in Python, from my first day on:
Look:
import random
import time
def drawn(a, b):
return random.randint(a, b)
answer = 'yes'
while answer == 'yes':
a = int(input('Min number: '))
b = int(input('Max number: '))
print(f'Drawn: {drawn(a, b)}')
time.sleep(2)
answer = input('Try again? ').lower()This creates a random number generator where you can choose the minimum and maximum numbers!
18
Upvotes
28
u/fazzah PyQt | SQLAlchemy | ReportLab 7h ago
good. now find a way to protect the script if someone inputs "foo"
4
u/Blinkinlincoln 7h ago
Nice
2
u/kilkil 3h ago
hell yeah! :D
what are you going to do next?
3
u/Available_Safe1818 5h ago
Very nice. Put one empty line after your function definition.
1
u/EnvironmentalDot9131 5h ago
This is good but need improvements
-4
u/zanfar 6h ago
drawn()if it accepts the exact same arguments asrandom.randint()? Why is it named as a passive verb when it does something?answeris badly named. There is zero context until the script is done.sleep()has almost no place in U/I.-1
u/Fast-Station1106 3h ago
jetzt hört mal auf, von 0 auf das oben? am ersten Tag?
so eine Quatsch zu posten versaut allen Anfängern doch komplett die Lust neu einzusteigen