The program is to measure the length of a string that is entered, but if an integer is entered; it should print "undetectable".
This program should return the output of the if
statement when it encounters an integer. Instead it just recognizes the else
statement, even in the case of an integer.
What could I be doing wrong here?
def string_length(mystring):
if type(mystring) == int :
return "undetectable"
else:
return len(mystring)
mystring=input("Enter the string: ")
print("The length of the string entered is: " + str(string_length(mystring)))