Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Need help with very simple python question.

How do I get it so when a name is inputted it will say Hello "name inputted"

This is what I have so far below.
print ("Hello")

input ("What's your name")
You need to store the input into a variable.

For python27:

PHP Code

<?php 
name 
= raw_input("What is your name-> ")
print 
"Hello %s!" % name 

OR

PHP Code

<?php 
name 
= raw_input("What is your name-> ")
print 
"Hello "+name 

For Python 3:

PHP Code

<?php 
name 
= input("What is your name-> ")
print (
"Hello %s!" % name) 

OR

PHP Code

<?php 
name 
= input("What is your name-> ")
print (
"Hello "+name) 


You should take some courses on www.codecademy.com (it's free). This is a very simple question and can be answered in the first 1-3 lessons 🤫
[Image: 5BgQiIm.gif]
2.7
Code
name = raw_input('What is your name? ')
print('Hello {}'.format(name))

3.x
Code
name = input('What is your name? ')
print('Hello {}'.format(name))
Thank You for the help it is now working!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 630 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by PlutoPicksSep 24, 2020 07:50 PM 4 162 Sep 24, 2020 07:50 PM
Last Post: Lindros
[Python] by ROIJun 15, 2016 12:05 PM 5 240 Jun 15, 2016 12:05 PM
Last Post: SIM-1866423