1

So lets say that i created a while loop where the user inputs a name and it outputs his last name

choice = input()
if choice == "Mark":
   print("Zuckerberg")
elif choice == "Sundar":
   print("Pichai")

but i want to help the user and when he types "help" a .txt file will open up and as i want it to be an infinite loop its going to be a while...(joke)

import os

choice = input()
while True:
    if choice == "Mark":
       print("Zuckerberg")
    elif choice == "Sundar":
       print("Pichai")
    elif choice == "help":
       howto = "notepad.exe howto.txt"
       os.system(howto)

as it is is going to run but when you open the file 'choice' is going to stop running resulting to not print out the surnames. if you close the .txt file it will continue but how do i make it work without closing the file?

Thanks in advance

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
mangafas
  • 43
  • 7

0 Answers0