198k views
4 votes
Assume that two variables, varA and varB, are assigned values, either numbers or strings. Write a piece of Python code that prints out one of the following messages:

• "string involved" if either varA or varB are strings
• "bigger" if varA is larger than varB
• "equal" if varA is equal to varB
• "smaller" if varA is smaller than varB

User Daltron
by
7.7k points

1 Answer

6 votes
strA = isinstance(varA, str)strB = isinstance(varB, str)
if strA or strB == True: print("String involved.")
elif varA > varB: print("bigger")
elif varA == varB: print("equal")
elif varA < varB: print("smaller")
User Neri Barakat
by
8.9k points