Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEric Roberts
924 PointsWhy do I get a "None" output in this script?
first_name = input(print("Type your first name here"))
last_name = input(print("Type your last name here"))
print( first_name, last_name, "is learning Python")
2 Answers
jb30
44,806 Pointsfirst_name = input("Type your first name here")
will print the string "Type your first name here" to the console and store the user's input in the variable first_name
. You don't need to use the print
function with the input
function.
When you pass the print
function to the input
function, the input
function will evaluate the print
function and print its value to the console. The print
function prints the string "Type your first name here" to the console and returns the value None
to the input
function, which then prints out the return value None
and then takes user input.
Unsubscribed User
Courses Plus Student 31 Pointsprint( None, "None")
Chris Freeman
Treehouse Moderator 68,454 PointsChris Freeman
Treehouse Moderator 68,454 PointsYep!