Need help with a Python Hello World

Hey guys, I’m working on a beginner Python course and completed the Hello World code for day 1:

input_string = input()

print(“Hello, World.”)

print(input_string)

Code above is correct, except I’m trying to understand why the output is:

Hello World.
Welcome to 30 Days of Code!

I do not understand how “Welcome to 30 Days of Code!” gets outputted this way without me actually typing it in the code. Appreciate any input, thanks.

How are you running this code? Where do you see this output?

@alaga-droid sounds to me that you are running the code in the course environment tbh because the code shouldn’t output this in real environment, Welcome to 30 Days of Code! will be background code and should only be on the first one

2 Likes

I’m running through this code through a compiler from (Hackerrank.com.https://www.hackerrank.com/challenges/30-hello-world/problem). After reviewing again, I think this “Welcome to 30 Days of Code!” is just a stored input string variable for the course that gets called with the print(input_string) command? Not sure if this makes sense to you, but this is the only way I can explain it to myself. Please let me know if you have a better explanation.

You’re right @biscuitmanz, the entire output doesn’t populate on my python 3.8 compiler. I’m working on the compiler built into the ‘30 days of code’ course at hackerrank.com.

1 Like

I recommend using repl.it to interact with the code and see what is going on. You will be prompted to type in an input when you run this in an interactive environment.

Side note, you should make sure that you are learning Python 3 and not Python 2. I see this covered in your second reply.

Other side note, Python has an interperter rather than a compiler. It’s possible to compile Python, but it’s very uncommon.

1 Like

@JeremyLT thank you for the feedback and suggestions, I’ll definitely start using repl.it:-)

1 Like

@biscuitmanz thank you for the feedback, I appreciate it. I guess I’ll just keep this in mind when going through the course and have a separate interpreter to verify the code.:slight_smile:

1 Like

i wish you the best in your journey mate :grinning:

try this. I did and voila.

‘’

Read a full line of input from stdin and save it to our dynamically typed variable, input_string.

inputString = raw_input()

Print a string literal saying “Hello, World.” to stdout.

print ‘Hello, World.’
print ‘Welcome to 30 Days of Code!’

TODO: Write a line of code here that prints the contents of input_string to stdout.

@nealelons thank you