Print, Comments, and Strings
Lesson 2 of 48 in Coddy's Python for JavaScript Developers course.
Print readable messages and keep comments out of program output.
JavaScript
// A note for the reader
console.log("Status:", "ready");
console.log("Don't stop");Python
# A note for the reader
print("Status:", "ready")
print("Don't stop")What changes
Both complete programs print the same two lines. Python calls print directly rather than accessing console.log. With several arguments, print places a space between them and ends the line with a newline. A single-quoted or double-quoted literal creates a string; choose the surrounding quotes so the text is easy to read. The quotes delimit the value and do not appear in output. Python starts a line comment with #. It continues to the end of that source line. A hash inside quotes remains ordinary text. These examples do not need JavaScript-style semicolons.
Common mistake
Do not copy // as a Python comment marker: it is an arithmetic operator. An apostrophe inside single quotes must be escaped, or you can use double quotes around the whole string. Extra debugging output also changes the answer that a challenge checks.
Your task
Keep the provided line-reading expression, disable the diagnostic, and print the required second line. Input text is data, so quotes and hashes within it must survive unchanged.
Challenge
BeginnerInput is one line of text, which may be empty or contain quotes or #. Print Message:, one space, and that exact text on the first line. Print It's Python on the second line. Remove or comment out the diagnostic print in the starter. input() is supplied here to read one line without its final newline.
Print only the requested output, with a newline after each line. The supplied input lines read the test data; keep them and add your work below.
Your code goes in main.py. The locked driver.py starts your program and cannot be edited.
Try it yourself
# Starts the program in main.py. Edit main.py to solve the challenge.
from runpy import run_module
run_module("main", run_name="__main__")
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Python for JavaScript Developers
1From JavaScript to Python
Run Your First Python ProgramPrint, Comments, and StringsVariables Without let or constNumbers and ConversionBlocks Use IndentationRecap: Rewrite a Receipt4Iteration and Transformations
for Loops Iterate ValuesIndexes and Dict Iterationwhile, break, and continueComprehensions and SortingRecap: Build a Ranking2Values and Decisions
None, True, and FalseEquality and IdentityTruthiness and Short-CircuitBranches and ExpressionsRecap: Eligibility Rules3Collections and References
Lists Instead of ArraysTuples and UnpackingDictionaries and RecordsSets, Aliasing, and CopiesRecap: Clean an Inventory6Reliable Python Programs
Input and Output ContractsExceptions and ValidationModules and the Main GuardReading Type HintsRecap: Validate a Batch9Project: Order Processing
Create the Order ModelAdd Pricing PoliciesPractice on your own: Online Python compiler