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

8
  • 3
    subprocess.Popen(howto) Commented Aug 21, 2016 at 1:54
  • @Rawing Are you sure about that? Docs says "Wait for command to complete" Commented Aug 21, 2016 at 1:56
  • 1
    @Rawing: I think he wants subprocess.Popen([howto]). python will wait for a termination signal to continue when using call Commented Aug 21, 2016 at 1:57
  • @cricket_007 My bad, I shouldn't be posting at 4am I guess. Commented Aug 21, 2016 at 1:58
  • @Rawing i didn't even understand how to use subprocess its an unresolved reference if i put in my code right away Commented Aug 21, 2016 at 1:59

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.