Hi jg789,
Edit: my original post is below, but it does look like you are running the old version of the code. We posted an updated version of the code that we believe will fix the spacing errors. Can you try re-downloading the code from
https://www.sciencebuddies.org/science- ... #materials, run it and see if you get the same errors?
Original post:
Thank you for posting a screenshot - several users have reported issues with this code, but no one has gotten back to us about the exact error messages they were seeing, so it has been difficult to troubleshoot.
Python uses indentations to organize code. One "indent" is equal to four spaces. So, for example if you want
print statements inside an
if/else statement, it should look like this:
Code: Select all
if x == 1:
print("Stuff")
else:
print("Other stuff")
Nested code must be indented in multiples of 4 spaces (4, 8, 12, 16...). If something is off by just one space, that will cause an error.
Looking at your screenshot - somehow, the spacing on all those
print statements inside the
else statement got really messed up. Everything immediately below the
else: should be indented 8 spaces. Below is a screenshot of what the original code looks like on my computer. Notice how the
print statements are all nicely lined up with each other. So - we need to figure out how these spaces got messed up on your computer but not mine.
Can you let me know:
- Did you edit the code at ALL after downloading it? Or did it look like that as soon as you opened the file?
- What day did you download the code? We uploaded a new version of the code on October 31st that I
thought would fix the spacing issues. If you downloaded the code after that, then clearly there is still a problem.