mercredi 1 juin 2022

add +1 to random range stopping point

hey I started programming and I have this problem maybe u can help me the following code creates a random number range from ut starting value up to ur stopping value -1

is there a line of ode that i can add so that it takes my stopping value and adds one to it with no errors ?

I have already tried with range_stop = int(range_stop) +1 but it didn't work out.

thank you, have a nice day

range_stop = input("type a number for ur stoppping point of the range: ")

if range_start.isdigit():
    range_start = int(range_start)
    if range_start < 0:
        print("please make sure to type no negative numbers")
        

if range_stop.isdigit():
    range_stop = int(range_stop)
    if range_stop <= 0 and range_stop <= range_start:
        print("please make sure to write a stop value that is greater than 0 and the start value")

r = random.randrange(range_start, range_stop)



Aucun commentaire:

Enregistrer un commentaire