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 trial

Python Python Basics (Retired) Things That Count Basic Numbers

Kollyn Lund
Kollyn Lund
20,644 Points

Will the input() object always output data as a string by default? Thanks!

Will the input() object always output data as a string by default? Thanks!

1 Answer

Tobias Edwards
Tobias Edwards
14,458 Points

You ask if input() will output data as a string. In that case, no. This is because you could output a variable through input() or a string:

a = "hi"
input(a)   # asks user for input and prints the variable 'a'

input("Hi")    # asks user for input and prints the string "Hi"

However, I think you're asking whether input() takes in input from the user as a string by default. In that case, your answer is simply yes:

input("input something: ")      # this is the same as the one below
str(input("input something: "))     

Both functions will take in input by the user as a string.

Kollyn Lund
Kollyn Lund
20,644 Points

thank you very much for the response. this makes sense :)