Ask coding questions

← Back to all posts
This is my Python 2.7 REPL (The best I can do as REPLIT DELETED PYTHON 2.7!!!) and I have an "error"
IndyRishi

I have a "string error"? Global string not defined? Huh? I have an input and whatever I input it gives an error.

Voters
CodingElf66
IndyRishi
Comments
hotnewtop
CodingElf66

You need to name your main file main.py, or it'll not even run, but I see that that's solved. Now, here is the error:

Whenever you make a global variable, you need to initialize that its global FIRST, then assign it.

What you've down is quite the opposite.

Do this:

And, raw_input isn't defined, so I suggest you change it to input.

Edit: Now you can mark this as answered!

IndyRishi

@CodingElf66 OK! Thanks! One question: wasn't raw_input a function in Python 2.7? It saves me some time in converting everything to strings.

CodingElf66

@IndyRishi Oh ok then, because I use Python 3.0. And if you don't mind, can you mark it as answered? That way, people know whats correct, this will be helpful!

IndyRishi

@CodingElf66 Ok. But the whole point of me making the REPL in Nix was because I wanted to make this a Python 2.7 REPL.

CodingElf66

@IndyRishi oohh. ok

CodingElf66

@IndyRishi Mark as answered? Click the check mark next to my answer, thank you so much!

IndyRishi

@CodingElf66 But your answer doesn't work!

CodingElf66

@IndyRishi Wait what? Global is supposed to work. Then its Python 3.0 syntax compared to the other one, then. Idk

IndyRishi

@CodingElf66 Well it doesn't work

IndyRishi

@CodingElf66 Can you upvote so more people can see it? I need this to be fixed

CodingElf66

@IndyRishi Ok let's both upvote each others comments!

CodingElf66

@IndyRishi Upvote my comments, because I upvoted your post.

IndyRishi
CodingElf66

@IndyRishi I'll do it to you, too!

eduardskasparov

nabags

IndyRishi
RoBlockHead

Python 2.7 is no longer supported, as it was sunsetted two years ago. You should use python3 nowadays

IndyRishi

@RoBlockHead Python 2.7 isn't supported; you're right. But the whole point of making this a Nix repl was so I can use Python 2.7 by installing the package pypy. You can see this via the config file visibility option.