+ 2
tic_tac_toe error
i just wrote this code and after a lot of debugging😧 i made it work well in Python 2 But when i enter any character except for the numbers then it pops NameError, I added that in the exception too but still it pops nd the code stops when i hit a character The code is here👇 https://code.sololearn.com/cLu30FboF4D0/?ref=app
3 Antworten
+ 1
python 2 input is a function that combine with eval function. which mean, it will execute the command just like exec or eval.
now try this in python 3
exec(input("what: "))
and you type "import os"
now you really importing os module.
using input in python2 is like a security hole.
solution :
use raw_input("answer: ")
it will return normal string.
or you can do import __future__
+ 1
oh sorry, __future__ for print function. for input, use import builtins. than you will able to use normal input like in py3
actually its funny using input in python2.
input("answer: ")
type exit(). :v
edit:
source:
http://hplgit.github.io/primer.html/doc/pub/input/._input-solarized010.html
0
u mean import__future__input ?