dimanche 20 juin 2021

How to find a random number between 2 numbers?

I am making a program that asks for 2 random numbers and prints a random integer between the 2 numbers that have been asked for. My code works except for the times where I give 2 consecutive numbers, it won't print a decimal/float.

import random

def bound():
    print("Give me a number")
    s = input()
    print("Give me another number")
    x = input()
    w = random.randint(int(s),int(x))
    if w == s:
        None
    if w == x:
        None
    else:
        print(w)
bound()



Aucun commentaire:

Enregistrer un commentaire