Spaces:
Paused
Paused
| def simulate_python_interpreter(): | |
| print("Python 3.9.7 (default, Sep 3 2022, 02:21:24)") | |
| print("[GCC 11.2.0] on linux") | |
| print("Type 'help', 'copyright', 'credits' or 'license' for more information.") | |
| while True: | |
| try: | |
| print(">>> ") | |
| user_input = input() | |
| if user_input.lower() == 'exit()': | |
| print("Exiting Python interpreter simulator.") | |
| break | |
| result = eval(user_input) | |
| print(result) | |
| except Exception as e: | |
| print("Error:", e) | |
| if __name__ == "__main__": | |
| simulate_python_interpreter() |