Weird problem with EX5.py

I feel rather dumb asking a question when I’m only on page 24 of Zen’s book, but I am stumped. When I call up the Ex5.py file in the Win PowerShell, it doesn’t come back with the answers filled in, but asks the questions, such as, “Let’s talk about (my name)”. Whereas it should say, “Lets talk about Zed Shaw”. What am I doing wrong? My other lessons, ex1.py through ex4.py worked great. Thank you in advance. I am Not2smart.

With your question you can add your code or part of it so if anyone wants to help they can assist you more efficiently. Without the code there could be many things that went wrong.

When posting your code make sure to sourrand it with (code) and (/code)

Just replace the ( ) with [ ]
This will make it more readable.

Based on your example above did you write:

“Let’s talk about {my_name}”

Or did you replace with normal parentheses like your question on here:

“Let’s talk about (my_name)”

It’s a subtle difference but means very different things…

1 Like
my_name = 'Zed Shaw'
my_age = 35 # not a lie
my_height = 74 # inches
my_weight = 180 # lbs
my_eyes = 'Blue'
my_teeth = 'White'
my_hair = 'Brown'

print(f"Let's talk about (my_name).")
print(f"He's (my_height) inches tall.")
print(f"He's (my_weight) pounds heavy.")
print("Actually that's not too heavy.")
print(f"He's got (my eyes) eyes and (my_hair) hair.")
print(f"His teeth are usually (my_teeth) depending on the coffee.")
# this line is tricky, try to get it right
total = my_age + my_height + my_weight
print(f"If I add (my_age), (my_height), and (my_weight) I get (total).") 

Easy, you’re doing this:

(my_weight)

But I’m not using that character. I’m using { and }. That’s the left curly brace { and right curly brace }. Look at my code again and see the difference.

Thank you Zed. gpkesley set me straight on my mistake. I tried to email him a reply but the site would not let me. I have moved on and now I’m on ex7. I learned to read the directions a little closer from that. I’m finding something in every lesson that I don’t understand why it is in there, but will expect to find the answers as I go along. I’m having more fun with this book and Python. I have tried learning Visual Basic, Pure Basic and Liberty Basic with not much luck. Thank you. I am, Not2smart.

It’s definitely not about being smart, its about accuracy and attention to detail. I’ve tried to debug code for hours because it will not work, only to finally realise that I used a full-stop/period instead of a comma.

One tip @zedshaw taught us was to read the error messages (usually the last one is very helpful) as it can literally tell you where the problem is. But just to confuse you, sometimes it will be the line before (such as if you didn’t close your ").

I’m glad you are sticking with this. It get very rewarding when you solved a problem you’ve been hacking on all day!

Actually, this isn’t an intelligence problem because your brain is working against you in order to help you survive in the world.

If your brain made you focus on every tiny detail all the time you’d never be able to do higher level thinking. A lot of perception has to be automatic and intuitive for you to do even simple stuff. There’s also problems with how vision works like if you turn your head super fast your eye actually only catches the beginning and end of the move visually, but then your *brain fills in the blanks like a video editor making things up". Or, if you look at someone throwing balls you’ll get the size of the balls right visually. If I hand you a bat and ask you to hit them your brain will suddenly “crop down” and make the balls 150% size so you can hit them, but now you get the size wrong.

The main thing you’re doing when you learn to code is figuring out how to turn off these “enhancements” because you don’t need them to code. This also applies to drawing and painting. Your brain constantly lies to you about what you see and remember because that helps you get through life, but when you have to actually be accurate about what you see and remember it’s really just getting in the way.

1 Like

Another novice here with piqued curiosity…
I’m Learning Python the Hard Way on a mac with Terminal. Is this why the “f” in the above code is not used by me? Or curly braces either? There is that distinct of a difference in coding between operating systems?

It looks like you saw another answer in another thread, but I’m going to add some more to this:

If you ever see some code and wonder “why did they do that” in a programming language the answer is generally “because they did.” You can’t really change the base language so you just have to accept that they wrote it that way and go with it. Python is always right even when it’s wrong.

Now, when you wonder that about code written in Python, then study it and see if your own idea would work better. Usually that’ll tell you why they did it or teach you that it’s the only way that works.

Thank you, Zed! I really appreciate your teaching style: encouraging me to be a self-learner. That’s the best!

1 Like