0

From my understanding, NoneType means the returns object will be nothing. However, why is the code

print ("Hello")

be a NoneType? It prints the str 'Hello'.

Say it is a NoneType type because the word ("Hello") is not saved in the memory. Then why is the code

input("What is your name?")

be a str ?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Math Avengers
  • 762
  • 4
  • 15
  • Could you rephrase your question? – Haris Muzaffar Oct 28 '19 at 16:38
  • 2
    The purpose of `print` is to print some text, not to _return_ anything. It doesn't need to return anything. Whereas the whole purpose of `input` is to get a string from the user, and you get it via its return value. – khelwood Oct 28 '19 at 16:38
  • `NoneType` is the class (i.e. type) for the language-guaranteed singleton `None`, i.e. `type(None)`. So, what you are seeing here is that `print` returns `None`, which it does. `input`, on the other hand, returns a `str` always. – juanpa.arrivillaga Oct 28 '19 at 18:02

0 Answers0