Help for a newbie


Joined
Feb 13, 2023
Messages
5
Reaction score
0
I'm trying to learn to code but i'm not finding it easy

I'm up to here so far and i've hit a brick wall


The question is

'
'Using the trinket IDE below, write a program that asks a user to input their name and then displays a message that welcomes the user by name.

Example output for program: Welcome Mike!

Remember to use the input command to get information and the print command to output information to the user.'


If I copy and paste the answer they give, it would be

name = input("What is your name?")
print("Welcome " + name + "!")


Obviously i've got to arrange it to say 'welcome mike'

So far i've tried

name = input("Mike")
print("Welcome " + name + "!")

But the trinket says 'Mike' and nothing else


I Know it's my first post, so i'm not sure if it's okay to just ask for help straight away but I wondering if anyone could help out?

thanks
 
Ad

Advertisements

Joined
Sep 21, 2022
Messages
52
Reaction score
8
Someone on the forum might give a clear explanation about what "input" and "print" do. Which will stroke their ego but that will not help you in the long term.

Some things, you have to figure out yourself.

Programming is about problem solving.

I had trouble with the GOTO command in BASIC on a ZX81 home computer. I would change the number and the program would mysteriously behave in different ways.

Turns out that the number after GOTO was a line number, and GOTO is two words, GO TO.

Took a while to figure out. Feel free to mock me.
 
Joined
Feb 13, 2023
Messages
5
Reaction score
0
If it was an exam my final answer would be

name = input('Welcome Mike!')

I think it might fail because I don't type 'print' ,but the trinket says exactly what the original question asked 'Welcome Mike!'
 
Joined
Dec 10, 2022
Messages
36
Reaction score
10
All this line is doing is saying if input is empty assign Mike. If input has a value then use the value.
 
Joined
Feb 13, 2023
Messages
5
Reaction score
0
Okay, i've settled on

name = " Mike"
print("Welcome" + name + "!")

I'm 90% certain i'm correct this time

I had to leave a space between the first " and the M otherwise it would look wrong on the trinket, if that isn't a big deal then I think i've done it right this time
 
Ad

Advertisements

Joined
Feb 6, 2023
Messages
39
Reaction score
2
No you are not getting an input? The problem wasn't with your code, but you weren't providing an input. But you could replace input("Mike") with input("What's your name?")
 
Joined
Feb 13, 2023
Messages
5
Reaction score
0
No you are not getting an input? The problem wasn't with your code, but you weren't providing an input. But you could replace input("Mike") with input("What's your name?")
If i type what I said the trinket says - 'Welcome Mike

If i change Mike for input the trinket says - Welcome input!

Surely it's better for it to say 'welcome mike'?
 
Joined
Feb 13, 2023
Messages
5
Reaction score
0
The sample code says

name = input("What is your name?")
print("Welcome " + name + "!")

But that doesn't ,make sense as they want the trinket to says 'welcome mike!'
 
Ad

Advertisements

Joined
Feb 6, 2023
Messages
39
Reaction score
2
You are supposed to give an input. When you use the function input, it propmts the user for an input, and when the input is mike, it prints hello mike. So just coding print(“hello mike”) doesnt make sense. That’s not how coding works. You wanna be as general as possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top