https://codewars.com/kata/5dd462a573ee6d0014ce715b
Write a function that will check if two given characters are the same case.
- If either of the characters is not a letter, return
-1
- If both characters are the same case, return
1
- If both characters are letters, but not the same case, return
0
Examples
'a'
and'g'
returns1
'A'
and'C'
returns1
'b'
and'G'
returns0
'B'
and'g'
returns0
'0'
and'?'
returns-1
char1 = 'G'
char2 = 'a'
def is_same_case(char1,char2):
if char1.isupper() and char2.isupper or char1.islower() and char2.islower:
return 1
elif char1.isupper() and char2.islower or char1.islower() and char2.isupper:
return 0
else:
return -1
print(is_same_case(char1,char2))
print(char1.isupper())
print(char2.isupper())
It returns 1 instead of 0.