Exercise 24 not printing in windows terminal

Hey, I’ve been having some issues with exercise 24. I’ve read the code backwards, forwards, up, and down and I can’t seem to figure why when I try to print the file in terminal I don’t get any error messages, it just jumps to a new line and displays the file name that contains all of my .py files. I corrected all the errors that I’ve made, watched the videos and check for mistakes non stop over the last hour, am I doing something wrong with the code? It the first time I’m running into an issue like this and everything in the file is identical to what is in the book including indentation, spelling, and formatting.

Hello and welcome to the forum @Nickconcadora.

I have been in this situation before. And still happens now and then.
If you put up your code in here there is a lot of eyes that can see the things oneself doesnt see.

Copy and paste in like this.

Code here

Hey, @ulfen69! Thanks for the response! This is what I have in right now and I’ve checked for mistakes over and over and can’t seem to find what’s wrong. I even rewrote out the code 3 separate times and can’t get it to display in the terminal.

print("Let's practice everything.")
print('You\'d need to know \ 'bout escapes with \\ that do:')
print('n\ newlines and \t tabs.')

poem = """
\tThe lovely world
with logic so firmly planted
canot discern \n the needs of love
nor comprehend passion from intuition
and requires an explanation
\n\t\twhere there is none.


five = 10 - 2 + 3 - 6
print(f"This should be five: {five}")

def secret_formula(started):
    jelly_beans = started * 500
    jars = jelly_beans / 1000
    crates = jars / 100
    return jelly_beans, jars, crates

start_point = 10000
beans, jars, crates = secret_formula(start_point)

# remember this is another way to format a string
print("With a starting point of: {}".format(start_point))
#it's just like with a f"" string 
print(f"We'd have {beans} beans, {jars} jars, and {crates} crates.")

start_point = start_point / 10

print("We can also do that this way:")
formula = secret_formula(start_point)
#this is an easy way to apply a list to a format string 
print("We'd have {} beans, {} jars, and {} crates.".format(*formula))

I hope this is correct, I’m fairly new to this stuff so any help or constructive criticism would be extremely helpful!

Hello @Nickconcadora

I see only one thing in your code that casued an error for me.
On the second line there was a blank space before bout in:

print('You’d need to know \ ‘bout escapes with \ that do:’)

There is three ways to do if you want a single or double quote in a string that is to be printed out.

  • You can use a \ just before the qoute. print(’ \‘Text\’ ')
  • Or you can use double qoutes to surround single quotes. print( ’ “text” ')
  • Or single quotes around double qoutes. print( " ‘text’ ")

But it was strange you didn’t get any error.
Do you have Windows or Mac? Perhaps Linux?
How do you run the code? Powershell? Terminal?
Other way?

@ulfen69 Thanks for the response! However, I corrected it and still can’t get the .py file to open in the Terminal. I’m using a Windows computer and have tried to open it in both the Powershell and command prompt. Still, I’m having no luck even with the correction. I posted it to another forum as well and they showed me the same mistake you pointed out but I’m still not having any luck.


I suppose you do the same way as usual when running a file, but with no success with this one?

How about the file name?
Once I accidentally typed a ”-” instead of a dot at the end (.py)

Have you tried to run with Python IDLE?

Is there no reactions at all when you try to tun it?

@ulfen69 Hey! Thanks for the response. I’m almost ashamed in admitting what my mistake was because it was such a brain fart and I was overthinking the issue. I did not save the file in Atom before trying to run the program in the Terminal and because of that, it was displaying a blank .py file. Thanks so much for all the help and feedback, truly appreciate it!


Hi @Nickconcadora

No problem. I am glad to help as long as my knowledge and experience admit.

Hey @Nickconcadora, are you saying that this code for esx24.py opens and prints out the ex24.py file? I actually can’t see from this code how that’s possible, so I’d love to see a screenshot of this or a small video. Some things to check as well:

  1. Are you running the right file? Use cat to view the file you think your running:

cat ex24.py

  1. Did you cd to the wrong directory? Maybe there’s an old ex24.py there?

Hi @zedshaw, I actually was able to correct the mistake quite easily. All I had to do was save the file in Atom in order to get it to display in the terminal. It was kind of a brain fart, there were no errors in the code just my mistake for not saving the ex24.py file before trying to run it in the terminal! Thanks for the response, I’m making some major progress with your LP3THW book so it was awesome to get a response from you, thanks!

I thought so. I really wish text editors could tell when you switch to the terminal and then yell at you to save. Anyway, good you figured it out.