Custom command for Input functions
[deleted]
Heya, I'm trying to make an application in Python. Do you know how I can make it so, if someone types /exit
in any input, it shuts down? I already know how to make it shut down by using the os
package...
import os os.system('exit')
All I need to do is add that "command" for all inputs. I just need a simpler way instead of adding "if input = "\exit" then os.system('exit')"
all the time.
Any help is appreacited!
Voters
Hello. You can put them into a dict and then loop through the keys.
Hopes this helps!
@Coder100 Thank you for answering. I'm quite new to Python, can you show me an example?
sure! @zinxcode
@Coder100 Tysm
Hopes this helps!
@zinxcode
@Coder100 So if a user says "exit", it will exit. Alright cool. Tysm
no problem! @zinxcode