I have made a code. It works like we are running the original python. It uses eval and exec. When I try to make a function or any if statement in it ,it don't works. Here is the code:
print("Python\n")
while True:
command =input(">>> ")
if command == "quit()":break
try:
try:
eval(command)
except:
exec(command)
except Exception as err:
print("Exception: "+str(err))
Running:
Python
>>> a = input("Enter your name: ")
Enter your name: abc
>>> print(a)
abc
>>> if True:
Exception: unexpected EOF while parsing (<string>, line 1)
>>> if True:print(a);if a == "abc":print("Great Abc")
Exception: invalid syntax (<string>, line 1)
>>>
if True:fails because something needs to come after the:. You can putpassthere.evalcan't know that. You can try(if Trueand then press enter, but I doubt it will work. Again, why are you trying to reinvent REPL?