0
I was wondering if you could use the type
thus:
media = input("Digite o numero: ")
média = input("Digite outro numero: ")
if media == type('str'):
print("oi")
else:
print("Tchau")
That is, to check whether the variable media
is str
, and if it is, print a message.
If it’s not, then it goes on.
I wanted to use this for a calculator. In case it puts something other than int
or float
, say you can’t put characters in such a place.
is right - but the most common is to use the call
isinstance
. Would be:if isinstance(media, str):
– jsbueno