-3

I'm trying to write a simple program that detects wether or not a string is upper case, lower case or mixed case.

I tried x.ismixed but it doesn't work

I have also tried x == mixed.case

This is the code:

x = input('Loud: ')

if x.isupper():
  print("Quiet:", x.lower())

elif x.ismixed():
  print (x.lower)

else:

  print (x.lower)

The error code comes up with

built-in method lower of str object at 0xf70445e0

The output should be x.lower() but instead comes up with the code above.

Input: HEllO ThEre
Output: hello there.
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
B.G ._.
  • 65
  • 1
  • 7

4 Answers4

0

That's not an error, it's just that you are not calling the function with (). Also, ismixed is not a built-in, you have to write it yourself:

def ismixed(s):
    return any(c.islower() for c in s) and any(c.isupper() for c in s)

x = input('Loud: ')

if x.isupper():
  print("Quiet:", x.lower())
elif ismixed(x):
  print(x.lower())
else:
  print(x.lower())

However, because you are printing x.lower() in either case, you can get rid of the whole elif block and ismixed.

iz_
  • 15,923
  • 3
  • 25
  • 40
0

Use x.lower() instead of x.lower. To call a method you need to add () to it. Also there is nothing like ismixed method in python.

s="Hello I'm a mixEd Sting"
if s.isupper():
 print("Upper case")
elif s.islower():
 print("Lower case")
else:
 print("mixed case") 
print("Lower Case", s.lower())
azhar22k
  • 4,765
  • 4
  • 21
  • 24
0

lower is a method you have to invoke it using () and mixed is not a function of string, you can simplify your function as below because elif is redundant

x = input('Loud: ')
if x.isupper():
    print("Quiet:", x.lower())
else:
    print (x.lower())
Sunder R
  • 1,074
  • 1
  • 7
  • 21
0

It should be x.lower() instead of x.lower. It should be a method call not a member variable.