mardi 25 juin 2019

I cannot get my program to stop repeating my first statement

Python just keeps repeating back to me "How many random numbers do you want?" and won't move on to the next input.

I've tried most things I could think of.

do_program = True while(do_program): while(True): try: number_of_numbers = float(input("How many random numbers do you want?")) if(number_of_numbers < 0): print("Negative numbers are not allowed.") continue except ValueError: print("The value you entered is invalid. Please enter numerial values only.") else: break

while(True):
    try:
        lowest_number = float(input("What is the lowest random number you want?"))
        if(lowest_number < 0):
            print("Negative numbers are not allowed.")
        continue
    except ValueError:
        print("The value you entered is invalid. Please enter numerial values only.")
    else:
        break

while(True):
    try:
        highest_number = float(input("What is the highest random number you want?"))
        if(highest < 0):
            print("Negative numbers are not allowed.")
        continue
    except ValueError:
        print("The value you entered is invalid. Please enter numerial values only.")
    else:
        break
import random
print("The numbers were written to randomnum.txt.")

def main():
    for count in range(number_of_numbers):
        number = random.randint(lowest_number, highest_number)
        print(number)
main()

Right now I just want to focus on getting to my second and third input statements.




Aucun commentaire:

Enregistrer un commentaire