-2

Struggling to work out why python complaining at line 4:

import sys
import re
problem = input("What is wrong with your mobile device?").lower
water = re.search(r'water', problem)
screen = re.search(r'screen', problem)+ re.search(r'smashed',problem)or re.search(r'cracked',problem)+ re.search(r'display',problem)
software=re.search(r'software',problem)+ re.search(r'program',problem)
keypad=re.search(r'keypad',problem)+ re.search(r'keyboard',problem)+ re.search(r'text',problem)
speakers=re.search(r'sound',problem)+ re.search(r"can't here",problem)+ re.search(r'cant hear',problem)
microphone=re.search(r'microphone',problem)+ re.search(r'cant hear me',problem)+ re.search(r"can't hear me",problem)
battery=re.search(r'battery',problem)+ re.search(r'swollen',problem)
charger=re.search(r'Charger',problem)+ re.search(r'charge',problem)+ re.search(r'charging',problem)
if water:
    print("If your phone has suffered water dammage there is not much you can do, it is recomended that you buy a new phone")
    sys.exit
elif screen:
    print("If your screen is cracked then it is recomended that you get it repaired this is not too expensive.")
    sys.exit
elif software:
    print("If you have a software issue then contact the product manurfacture, they are the only ones qualified to fix this.")
    sys.exit
elif keypad:
    print("Clean your keypad with a wetwipe, do not get the charger port or jack port wet.")
    sys.exit
elif microphone:
    print("Your microphone hole may be blocked, please clean this with a soft dry tooth brush, if this does not work then please retern the hand held device to its manufactures.")
    sys.exit
elif battery:
    print("If your battery is enlarged/swollen you have probbaly over charged it it is recomended that you buy a ned battery.")
    sys.exit
elif speakers:
    print("The speaker on most phone is located on the side or back or the device if this is blocked then please attemt to clean this with a dry, soft toothbrush, if this does not work please contact the product manurfacture.")
    sys.exit
elif charger:
    print("If you have not tryed buying a new charger then try that. If a new charger does not work, please send your mobile device to the product manurfacture.")
    sys.exit
else:
    print("please write your problem again, attempt to use keywords that relate to your problem.")
    sys.exit

If someone could tell me how to correct this or correct this themselves it would be much appreciated.

Chr
  • 875
  • 1
  • 10
  • 27
  • 5
    Please check your formatting before posting; your current code is unreadable (use Ctrl+K to get indented code blocks which are formatted properly). Also, please include the *full* error message so we can see it more easily. – Aurora0001 Nov 16 '16 at 16:12

2 Answers2

4

you are not calling the function lower in line 3. In order to call it, you have to write 2 parenthesis after it. Thus, correct that line as follows:

problem = input("What is wrong with your mobile device?").lower()
Jalo
  • 1,131
  • 1
  • 12
  • 28
1

The problem is actually on line 3. According to this article, Python 2 uses raw_input to get input, while Python 3 uses input. It looks like your code is expecting a Python 3 environment, but your environment is actually Python 2.

You can replace your call to input with a call to raw_input if you are, indeed, running in a Python 2 environment.

In addition, you must use parentheses after the call to lower so that the method actually gets called.

Python 2

problem = raw_input("What is wrong with your mobile device?").lower()

Python 3

problem = input("What is wrong with your mobile device?").lower()
Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
  • I don't really think that is the problem – Jalo Nov 16 '16 at 16:21
  • @Jalo, it depends on if it's Python 2 or 3. If he's running in Python 2, then my solution would fix it (without needing to add parentheses at the end of the call to `lower`). If it's Python 3, then you're right – Chris Forrence Nov 16 '16 at 16:22
  • The solution I posted works equally on Python 2 and Python 3. The difference is that with input function the user needs to enclose the input with quotes – Jalo Nov 16 '16 at 16:23
  • Anyway, parentheses are mandatory for calling the lower function – Jalo Nov 16 '16 at 16:27
  • @Jalo In Python 2, the method call `input` [evaluates](http://stackoverflow.com/a/4915408/899126) what gets provided as an expression. You could add quotes around it, and asking your users to do that each time would be pretty rough ;) – Chris Forrence Nov 16 '16 at 16:27
  • I am not sure if I am getting you. I am discussing about the **lower** function, not the input / raw_input functions. In order to use (call) the lower function, you have to use parentheses. If not you will only be assigning the function itself to the variable – Jalo Nov 16 '16 at 16:31
  • @Jalo I stand corrected; I could've sworn that, with Python open, I had called `.lower` and had it work. Do you know a good glasses place nearby, because apparently I need a pair – Chris Forrence Nov 16 '16 at 16:36
  • haha don't worry. Actually I guess I am much newbier than you are, and I was wondering were could I be failing. Problem solved then :) – Jalo Nov 16 '16 at 17:10