Question with type()

Hello. I’m working my way through the Scientific Computing with Python course, and am on this video specifically:

The type() function (If I get the technical term wrong please correct me. I’m just beginning to dip my toes in Python.) is given as an example to have Python show what type something is. For example integer or string.

When I try to test this myself using the same code presented nothing happens.

eee =  "Hello " + "there."
eee = eee + 1

I understand that line 2 is an example to show python cannot add integers and string. I’m keeping it there because it was in the example. I’ve tried #commenting it out or just deleting it as well, but type(eee) still does nothing.

It doesn’t seem to be a big issue, and won’t keep me from moving forward, but I’m just looking for help as to why it does work as shown.

Thanks in advance for any help to this really noob question.

Depending upon where you are running the code, you may need to print() the line to see the result:

eee =  "Hello " + "there."
#eee = eee + 1


<class 'str'>

On the video code is taken from the interactive console or the so-called repl - read, evaluate, print and loop. One version of it can be accessed by simply running python interpreter, without adding file to run in the command.

1 Like

This worked! I should have known to try the print() function because it has been covered, but I’ll remember in the future. Thanks so much!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.