Questions about type Python3

0

I wanted to know if I could use type like this:

media = input("Digite o numero: ")
média = input("Digite outro numero: ")

if media == type('str'):
    print("oi")

else:
    print("Tchau")

That is, to check if the variable media is str , and if it is, print a message.

If it is not, then it continues.

I wanted to use this for a calculator. If it puts something other than int or float , say that you can not put characters in that place.

    
asked by anonymous 07.07.2018 / 19:53

1 answer

1

You can, just put type on the other side.

media = 'exemplo'

if type(media) == str:
    print('oi')
else:
    print('tchau')
    
07.07.2018 / 20:10