Hack Forums
[Python] Need help with very simple python question. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Need help with very simple python question. (/showthread.php?tid=5549196)



Need help with very simple python question. - FrogSquad4 - Feb 11, 2017

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")


* - TheWarOwl - Feb 11, 2017

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 🤫


* - captainspalding - Feb 11, 2017

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))



* - FrogSquad4 - Feb 12, 2017

Thank You for the help it is now working!