so I was making this virtual bot on python using many modules out of which some were (os and random) so in this virtual bot it asks me what I want to do I respond to it and gives me outcomes based on what I asked or told it to do, So, I was trying to add another feature in this code, where, I ask it to play a game it asks me which game and I respond and it opens the game i tell it to
elif "jarvis play a game" in query or "jarvis play one of my games" in query or "jarvis play my games" in query:
speak("ok", "I have 6 games", "they are", "breakout arcade game", "car arcade game", "obstrucal course game", "football champs", "path finder", "and", "tic tac toe", "which of these games would you like to play?")
wgp = takeCommand().lower()
if wgp == "breakout arcade game":
speak("ok, opening breakout arcade game, have fun")
os.startfile("breakout arcade gaming.py")
elif wgp == "car arcade game":
speak("ok, opening car arcade game, have fun")
os.startfile("car arcade gaming.py")
elif wgp == "obstrucal course game":
speak("ok, opening obstrucal course game, have fun")
os.startfile("complete obby game! - ursina.py")
elif wgp == "football champs":
speak("ok, opening football champs, have fun")
os.startfile("football champs.py")
elif wgp == "path finder":
speak("ok, opening path finder, have fun")
os.startfile("path finder.py")
elif wgp == "tic tac toe":
speak("ok, opening tic tac toe, have fun")
os.startfile("tic tac toe2options.py")
elif wgp == "choose a random game":
speak("ok")
game = ["tic tac toe2options.py","football champs.py","complete obby game! - ursina.py"]
choose = random.choices(game)
os.startfile(choose)
this is only a part of the code so the elif statement is not an error, query is the thing that hears and saves what we say. So in this code everything works but the last elif statement where I try making it choose a random game between the given file names that they are saved as, it should choose on of those and i want the os.startfile to start a file that was randomly chosen between the given ones in the list but when i run this code it gives me an error saying
line 24, in <module>
os.startfile(choose)
TypeError: startfile: filepath should be string, bytes or os.PathLike, not list
[Finished in 0.6s with exit code 1]
[shell_cmd: python -u "C:\Users\Vatsa\OneDrive\Desktop\New folder\all main py files\pyautogui basics 2.py"]
[dir: C:\Users\Vatsa\OneDrive\Desktop\New folder\all main py files]
[path: C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Android;C:\Windows\System32;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Users\Vatsa\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\Vatsa\AppData\Local\Programs\Python\Python36\;C:\Users\Vatsa\AppData\Local\Microsoft\WindowsApps;C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\bin;C:\Users\Vatsa\AppData\Local\GitHubDesktop\bin;C:\Users\Vatsa\AppData\Local\atom\bin;C:\Users\Vatsa\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Vatsa\.dotnet\tools]
Can someone help me solve this??
thank you
Aucun commentaire:
Enregistrer un commentaire