FAQ: Introduction to Functions - Whitespace & Execution Flow

This community-built FAQ covers the “Whitespace & Execution Flow” exercise from the lesson “Introduction to Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Visualize Data with Python
Data Scientist
Analyze Data with Python
Computer Science
Analyze Financial Data with Python
Build Chatbots with Python
Build Python Web Apps with Flask
Data Analyst

Learn Python 3
CS101 Livestream Series

FAQs on the exercise Whitespace & Execution Flow

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

I’m stuck on step 3 of this exercise.

The directions ask: In our weather_check() function add a second print() statement under the first one which prints a warning message for our travelers! It should print: False Alarm, the weather changed! There is a thunderstorm approaching. Cancel your plans and stay inside.

This is what my code looks like after I add the second print statement:

# Your code below: print("Checking the weather for you!") def weather_check(): print("Looks great outside! Enjoy your trip.") print("False alarm, the weather changed! There is a thunderstorm approaching. Cancel your plans and stay inside.")

When I compare this to the actual solution, I can’t see a difference! But I must be doing something wrong because it’s not letting me progress. Any ideas what I’m missing or doing wrong? :frowning:

Hey there!

From what I can see, the it’s just a spelling error, False alarm should be False Alarm.

Hope it helps! :slight_smile:

2 Likes

Hello there,
I am also stuck on the step, the solution has the print() function outside of the weather_check() function and therefore contradicts step 3 written instructions.

Have you guys solve this issue? I am still get stuck on this

print("Checking the weather for you!") def weather_check(): print("Looks great outside! Enjoy your trip.") print("False alarm, the weather changed! There is a thunderstorm approaching. Cancel your plans and stay inside.") weather_check()
1 Like

I wanted to understand that when a function is called the unintended print statement is printed and then the print statement inside the function is printed. Why is that? I mean can anyone explain is that the correct flow I am understanding?

Hi,

does anyone know why an unindented print statement appears before and indented print statement in a function even if the indented print statement was defined before the unindented statement ?

I noticed that the instructions and error message request for the message to be indented within the function but the solution wants it to be outside the function. Should be fixed.

because the unindented print statement was called before the function was called

Your code below:

print(“Checking the weather for you!.”)
def weather_check():
print(“Looks great outside! Enjoy your trip.”)
print(“False Alarm, the weather changed! There is a thunderstorm approaching. Cancel your plans and stay inside.”)
weather_check()

This last question. I am stuck. I need urgent help. I cannot understand why I am unable to move on. The code comes out find but I cannot progress. Stuck. Any help is appreciated.

Hi #fareesa793, step 4 the two last print must be indented and step 5 you need to unindent the last print.
Hope is work for you.
Here is my final code:

print(“Checking the weather for you!”)

def weather_check():

print(“Looks great outside! Enjoy your trip.”)

print(“False Alarm, the weather changed! There is a thunderstorm approaching. Cancel your plans and stay inside.”)

weather_check()

1 Like

How do we create paragraph spaces between the lines of output? Or am I jumping ahead of myself?

It depends what you are printing. Is it literal text or numbers or are the values assigned to variables? Are you entering the print statement in the interactive shell or in a program?

Entering in the interactive shell (for now). I’m in the multiple parameters lesson now.

I plan to download the Juptyer notebook as well, unless there is a different program in which I should be using Python. Thank you!

Cannot advise what to use since I only use the Python shell. For working on projects it follows one will use the same environment as everyone else on the team (your collaborators).

In Python the rarely used/seen token is our favorite one from other languages, a semi-colon, which indicates end of statement, also means the same thing.

>>> print ('Hello World'); print()
Hello World

>>>

We can also use the newline character in our string:

>>> print ('Hello World\n')
Hello World

>>>

Thank you so very much! And now I have downloaded Python for my mac. I really appreciate your help!

1 Like

@devsolver55542 @andrewkiousis3176307

For that step (step 3) I would recommend just copy and paste the text from the instruction directly. If you look closely False Alarm are both capitalized, which is not present in your code. It’s very unintuitive and probably missed by the devs if you were just typing out the message yourself.

Hope that helps you guys and anyone else that’s stuck on that exercise!

I solved it!!

Copy paste it then rewrite it on your own sometimes it glitches so just delete the words and type them again and make sure that the only print that is indent is the 2nd one :slight_smile:

here’s the code:

print(‘Checking the weather for you!’)

def weather_check():

print(‘Looks great outside! Enjoy your trip.’)

print(‘False Alarm, the weather changed! There is a thunderstorm approaching. Cancel your plans and stay inside.’)

weather_check()

1 Like

For anyone else stuck on step 5:
1.) The “A” in “False Alarm,” is capitalized, as others have mentioned.
2.) If both strings are typed correctly, and you’ve unindented the 2nd print statement and it still doesn’t work, you may have to reset the workspace and type it out again. I’m not sure why, but this step was extremely finicky for me, and I had to type, retype, indent, unindent, multiple times until it finally worked.

Anyone else have a lot of trouble with this step?