I don't understand: L2 PROBLEM 11 : 5.0 POINTS 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 I thought it would simple enough to write: if varA > varB: print "greater" Am I missing something?
or here is some code I created in the Python shell that works for the equals: >>> varA = "hello" >>> varB = "hello" >>> if varA == varB: print "string involved" string involved
if type(varA) == str or type(varB) == str: print('string involved') elif varA > varB: print('bigger') elif varA == varB: print('equal') else: # If none of the above conditions are true it must be the case that varA < varB print('smaller')
I find the question very confusing. I thought it only wanted a few lines of code to print out one of the following messages. I didn't realize it wanted me to consider all the possibilities as an output. Is this the way questions are going to be written?
Join our real-time social learning platform and learn together with your friends!