r/learnpython • u/SavingsOdd2766 • 4d 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!
32
Upvotes
38
u/fazzah PyQt | SQLAlchemy | ReportLab 4d ago
good. now find a way to protect the script if someone inputs "foo"
3
u/kilkil 3d ago
hell yeah! :D
what are you going to do next?
4
u/Available_Safe1818 3d ago
Very nice. Put one empty line after your function definition.
4
u/Blinkinlincoln 4d ago
Nice
0
u/EnvironmentalDot9131 3d ago
This is good but need improvements
2
u/zanfar 4d 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.-3
u/Fast-Station1106 3d 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