In Python for Robotics Unit 3: Conditional statements and Loops, the examples in the cell being used is not working. In this Unit you are expected to create a python script under a folder and fill the script with the code provided from a cell in the kernel, shown below:
movie = input("What’s your favorite move? ")
if movie == “Avengers Endgame”:
print(“Good choice!”)
Then you are asked to execute the file.
Pretty simple and straight forward, right?
The dialog in the kernel goes on expressing as if the code worked, and provides a picture of what it should look like when executed correctly.
When I copy and pasted the code provided into the script and ran it, it came up with an error. I thought, it must of been something I did. I will try fixing it! I spent nearly 20 minutes experimenting trying to make this simple code work and even completely deleting the file and recreating it just in case. I went back into the kernel and ran the cell that provided the code, and the cell came up with an error, just like mine did in the shell. Here is the error that was stated from provided code in the cell:
What’s your favorite movie? Avengers Endgame
File “”, line 1
Avengers Endgame
^
SyntaxError: unexpected EOF while parsing
I have copied Avengers Endgame directly from the code and pasted it for input about a dozen and one times thinking I must of just been typing the movie wrong. This error still shows up.
I have looked through a lot of examples and ran them in the cell and most of them come back with an immediate error.
More example cells having errors:
1.
movie = input("What’s your favorite movie? ")
if movie == “Avengers Endgame” or movie == “Titanic”:
print(“Good choice!”)
error:
What’s your favorite movie? Titanic
NameErrorTraceback (most recent call last)
in ()
----> 1 movie = input("What’s your favorite movie? ")
2
3 if movie == “Avengers Endgame” or movie == “Titanic”:
4 print(“Good choice!”)
/etc/jupyter/lib/python2.7/site-packages/ipykernel/ipkernel.pyc in (prompt)
174 self._sys_eval_input = builtin_mod.input
175 builtin_mod.raw_input = self.raw_input
–> 176 builtin_mod.input = lambda prompt=’’: eval(self.raw_input(prompt))
177 self._save_getpass = getpass.getpass
178 getpass.getpass = self.getpass
/etc/jupyter/lib/python2.7/site-packages/ipykernel/ipkernel.pyc in ()
NameError: name ‘Titanic’ is not defined
movie = input("What’s your favorite movie? ")
if movie == “Avengers Endgame” or movie == “Titanic”:
print(“Good choice!”)
if movie == “Star Wars”:
print(“Also a good choice!”)
error:
What’s your favorite movie? Star Wars
File “”, line 1
Star Wars
^
SyntaxError: unexpected EOF while parsing
3.A
movie = input("What’s your favorite movie? ")
if movie == “Avengers Endgame” or movie == “Titanic”:
print(“Good choice!”)
elif movie == “Star Wars”:
print(“Also a good choice!”)
else:
print(“You really are an interesting specimen”)
error:
What’s your favorite movie? Star Wars
File “”, line 1
Star Wars
^
SyntaxError: unexpected EOF while parsing
3.B
(Same example cell, same code, different input.)
movie = input("What’s your favorite movie? ")
if movie == “Avengers Endgame” or movie == “Titanic”:
print(“Good choice!”)
elif movie == “Star Wars”:
print(“Also a good choice!”)
else:
print(“You really are an interesting specimen”)
error:
What’s your favorite movie? BeetleJuice
NameErrorTraceback (most recent call last)
in ()
----> 1 movie = input("What’s your favorite movie? ")
2
3 if movie == “Avengers Endgame” or movie == “Titanic”:
4 print(“Good choice!”)
5 elif movie == “Star Wars”:
/etc/jupyter/lib/python2.7/site-packages/ipykernel/ipkernel.pyc in (prompt)
174 self._sys_eval_input = builtin_mod.input
175 builtin_mod.raw_input = self.raw_input
–> 176 builtin_mod.input = lambda prompt=’’: eval(self.raw_input(prompt))
177 self._save_getpass = getpass.getpass
178 getpass.getpass = self.getpass
/etc/jupyter/lib/python2.7/site-packages/ipykernel/ipkernel.pyc in ()
NameError: name ‘BeetleJuice’ is not defined
These errors shows up when I run them in the shell and in the cells inside the kernel. If errors are occurring to the provided untouched code, it must not be my fault. Is this a bug? If not, Is this something I can fix? and if so, how do I fix it?
These example cells that are having errors are all the examples before the exercise. I have yet to attempt the exercise, Although when I do and if it also has errors I will update this post.
Thank you for reading this very long post! And Thank you for any potential help!!!