an assignment operator is expected with the eval operation
a semi colon is not specified at the end of a free format statement
the name or indicator is not defined
the compiler cannot determine how the program can end try this please
hope its clear for issue
#1 & 2 are pretty evident, the error tells the line number in the source with the problem, just fix it. #3 is pretty evident as well, the error will tell you the name of the variable that is not defined.
#4 is the only one that is a bit tricky if you haven't seen it before. The compiler did not find a return from the main procedure, and also no place that *INLR is set on. Either of those things will fix that one.
Odds are that you just included some typos in your code. Please don't paste the entire source and error listing, just read the errors, and go find someone in your company that can tell you where in the source listing to find the errors. Or if you are using RDi, you could just click on the error, and it will take you directly to the problem.
Please help me with this. I'd really appreciate it. I have tried alot of things but nothing is working, Please suggest any ideas you have.
This is what it keeps saying:
name = imput('hello')
NameError: name 'imput' is not defined
You misspelled input as imput. imput() is not a function that python recognizes - thus, it assumes it's the name of some variable, searches for wherever that variable was declared, and finds nothing. So it says "this is undefined" and raises an error.
imput isn't a built-in function. Perhaps you're looking for input.
I'm very new to Python and programming overall, so if I seem to struggle to understand you, please bear with me.
I'm reading "Learn Python 3 the Hard Way", and I'm having trouble with exercise 23.
I copied the code to my text editor and ended up with this:
import sys
script, input_encoding, error = sys.argv
def main(language_file, encoding, errors):
line = language_file.readline()
if line:
print_line(line, encoding, errors)
return main(language_file, encoding, errors)
def print_line(line, encoding, errors):
next_lang = line.strip()
raw_bytes = next_lang.encode(encoding, errors=errors)
cooked_string = raw_bytes.decode(encoding, errors=errors)
print(raw_bytes, "<====>", cooked_string)
languages = open("languages.txt", encoding = "utf-8")
main(languages, input_encoding, error)
When I tried to run it I got the following error message:
Traceback (most recent call last):
File "pag78.py", line 3, in <module>
script, input_encoding, error = sys.argv
ValueError: not enough values to unpack (expected 3, got 1)
which I am having difficulties understanding in this context.
I googled the exercise, to compare it something other than the book page and, if I'm not missing something, I copied it correctly. For example, see this code here for the same exercise.
Obviously something is wrong with this code, and I'm not capable to identify what it is.
Any help would be greatly appreciated.
When you run the program, you have to enter your arguments into the command line. So run the program like this:
python ex23.py utf-8 strict
Copy and paste all of that into your terminal to run the code. This exercise uses argv like others do. It says this in the chapter, just a little bit later. I think you jumped the gun on running the code before you got to the explanation.
Let's record this in an answer for sake of posterity. In short, the immediate problem described lies not as much in the script itself, but rather in how it's being called. No positional argument was given, but two were expected to be assigned to input_encoding and error.
This line:
script, input_encoding, error = sys.argv
Takes (list) of arguments passed to the script. (sys.argv) and unpacks it, that is asigns its items' values to the variables on the left. This assumes number of variables to unpack to corresponds to items count in the list on the right.
sys.argv contains name of the script called and additional arguments passed to it one item each.
This construct is actually very simple way to ensure correct number of expected arguments is provided, even though as such the resulting error is perhaps not the most obvious.
Later on, you certainly should check out argparse for handling of passed arguments. It is comfortable and quite powerful.
I started reading LPTHW a couple of weeks ago. I got the same error as 'micaldras'. The error arises because you have probably clicked the file-link and opened an IEExplorer window. From there, (I guess), you have copied the text into a notepad file and saved. it.
I did that as well and got the same errors. I then downloaded the file directly from the indicated link (right click on the file and choose Save Target As). The saves the file literally as Zed intended and the program now runs.
I am making a program in pygame and I am trying to create with buttons where the user can enter their name. So basically when ever they click on the letter, then it puts that letter into a list. I recreated with about the same variables as in my game and got the same error. So if we can fix this, then I can fix my game. I am using functions so that is why you see the global thing as that is needed. Here is the code. I have looked at other forums btw but nothing that is the same as mine.
import glob
unknown=[]
def bob():
global unknown
a=('a').upper()
unknown=unknown.extend(a)
unknown=','.join(unknown)
bob()
Again, this is basically what is in my code except for the name of the function and the name of the list, other than that it is the same. The name doesn't matter though. Thanks in advance.
I'm having trouble with the input() function in Python3.4 using the Anaconda integrated editor. If I just type
x = input()
into the editor, it returns a blank line that I can type text into. If I type:
foo
into this line, I would expect 'foo' be stored as a string with variable name x. But, instead I get:
NameError: name 'foo' is not defined
To make the function work as expected, I must instead type in:
'foo'
which is unfortunate because what I really want is just to pause my code and wait for an arbitrary user input, and I read somewhere that "wait = input()" is the most pythonic way to do this. Using that line in my actual script returns an "unexpected EOF" error - I assume as another symptom of the same problem. Can anyone suggest a workaround?
Note: I suspect this is an Anaconda-specific problem, given the following reference:
https://docs.python.org/3.4/library/functions.html#input
Thanks for your time.
Your code is being run by Python 2, not 3. I don't know enough about Anaconda to know if the problem is with their editor, or if you have your path messed up, but the problem is that the wrong version of Python is being used.