0
print("Hello Welcome To The Essay Generating Code")
print("")
print("First things first, you need to give your essay characters")
print("")
print("")
print("How many main characters would you like your story to have?")
number_of_characters = input("Number Of Characters:")
if number_of_characters <= "10":
    print("That's way too many characters!") 
else:
    # rest of code

I would like to redirect the user with the else function back to input the number of characters, how do I do that?

DeepSpace
  • 78,697
  • 11
  • 109
  • 154

1 Answers1

0

I would use functions for your purpose and use a while loop until you have the desired value.

def set_characters_number():
    print("Hello Welcome To The Essay Generating Code")
    print("")
    print("First things first, you need to give your essay characters")
    print("")
    print("")
    print("How many main characters would you like your story to have?")
    return (int(input("Number Of Characters:")))

number_of_characters = set_characters_number()

while (number_of_characters >= 10):
    print("That's way too many characters!")
    number_of_characters = set_characters_number()

# rest of code

or, if you don't want to display the welcome message again :

print("Hello Welcome To The Essay Generating Code")
print("")
print("First things first, you need to give your essay characters")
print("")
print("")
print("How many main characters would you like your story to have?")

number_of_characters = int(input("Number Of Characters:"))

while (number_of_characters >= 10):
    print("That's way too many characters!")
    number_of_characters = int(input("Number Of Characters:"))

# rest of code

By the way, I suppose too many characters is superior or equal to 10 (>= 10), not inferior or equal to 10 (<= 10) as you wrote it

Notice the int(input(...)) to cast the string from the input to an int, to make the numeric comparison possible

Cid
  • 14,968
  • 4
  • 30
  • 45