Ask coding questions

← Back to all posts
Python Function Not working
RobertFurr (49)

I was working on a new game and when I went to test the following:

if choice == 1:
  os.system("startgame.py")
if choice == 2:
  os.system("python readme.py")

No matter what I input, it won't open any files! It just stops the program. I went back to another program which I know works with this kind of function and it did the same thing. Was repl updated and this function removed?

Answered by CodeLongAndPros (1359) [earned 5 cycles]
View Answer
Commentshotnewtop
CodeLongAndPros (1359)

Was repl updated and this function removed?

No

Can you add this to your code?
print(type(choice))?

I have a hunch that you need to do this

if choice == "1":
  os.system("startgame.py")
if choice == "2":
  os.system("python readme.py")
CodeLongAndPros (1359)

@RobertFurr

Please mark it as the answer if it helped