>>> bob_string = 'Hi, my name is Bob.' >>> print(bob_string) Hi, my name is Bob.
It's that simple. You may notice that it doesn't have the quotation marks around it like:
>>> bob_string 'Hi, my name is Bob.'
The print function is used to display the value of something to the console (the interactive shell, IDLE, is a console). Strings by themselves won't print to the console inside of a function definition.
You can also print numbers!
>>> print(42) 42
You can even print print!!
>>> print(print) <built-in function print>
Using print is the simplest way to get feedback from your program. Use it liberally (at least until episode #163* where we discuss the logging package).
*yeah, right. I don't even have #4 planned yet...
No comments:
Post a Comment