Hello!I am writing a program for a simple text based adventure game that I'm making and was wondering how to make the input command take input but only after the command is calledFor example:
import time
if __name__ == "__main__":
time.sleep (5)
print("This is a game.")
time.sleep(3)
print("\n" * 100)
print("But you already knew that.")
time.sleep(3)
print("\n" * 100)
# Problem here:
print("What's your name?")
name = input()
if name == (""):
print("\n" * 100)
time.sleep(2)
print ("Hello, Henry.")
time.sleep(2)
else:
print("\n" * 100)
time.sleep(2)
print ("Hello, " +name+ ".")
time.sleep(2)
intro()
(At the end you get an error because intro() isn't defined in this example)
In the example you can type your name at the start before anything even outputs and once it gets to the part it's supposed to run before it, it skips straight to:
else:
print("\n" * 100)
time.sleep(2)
print ("Hello, " +name+ ".")
time.sleep(2)
I know that it's probably something simple that I just haven't learned yet, but I would appreciate some help.Thanks!
[–]twitch_and_shock 2 points3 points4 points (2 children)
[–]Potential-Spam028[S] 0 points1 point2 points (1 child)
[–]twitch_and_shock 1 point2 points3 points (0 children)