0
input=input("select the garment you purchased type 1 for shirt, 2 for pants, 3 for coats: ")

def color(call):
   if call==123:
      colorin=input("Enter your shirt colour, 1 for red, 2 for blue, 3 for green")
    elif call==345:
       colorin=input("Enter your pants colour 1 for black, 2 for blue, 3 for white")
    elif call==678:
       clorin=input("Enter your coat colour 1 for black, 2 for grey, 3 for skyblue")
    else:
       print("invalid")
    return colorin

def shirt(sh):
   if int(sh)==1:
      print("shirt red, cost=$5")
   elif int(sh)==2:
      print("shirt blue, cost=$6")
   elif int(sh)==3:
      print("shirt green, cost=$7")
   else:
      print("enter a valid color")
   return print("Thank you for shopping")

def pants(pa):
   if int(pa)==1:
      print("pant black, cost=$10")
   elif int(pa)==2:
      print("pant blue, cost=$11")
   elif int(pa)==3:
      print("pant white, cost=$12")
   else:
      print("enter a valid color")
   return print("Thank you shopping")

def coat(ca):
   if int(ca)==1:
      print("coat black, cost=$50")
   elif int(ca)==2:
      print("coat grey, cost=$55")
   elif int(ca)==3:
      print("coat skyblue, cost=$60")
   else:
      print("enter a valid color")
   return print("Thank you shopping")



if int(input) == 1:
   sc = color(123)
   las=shirt(sc)
else:
   pass
if int(input) == 2:
   pc=color(456)
   lap=pants(pc)
else:
   pass
if int(input) == 3:
   cc=color(678)
   lac=coat(cc)
else:
   print("enter a valid number")

end of code

error:

      select the garment you purchased type 1 for shirt, 2 for pants, 3 for coats: 1
    Traceback (most recent call last):
   File "c:\users\abdul samad\documents\visual studio 2017  \rojects\PythonApplication7\PythonApplication7\PythonApplication7.py", line 50, in <module>
    sc = color("123")
    File "c:\users\abdul samad\documents\visual studio 2017\Projects\PythonApplication7\PythonApplication7\PythonApplication7.py", line 5, in color
    colorin=input("Enter your shirt colour, 1 for red, 2 for blue, 3 for green")
    TypeError: 'str' object is not callable
    Press any key to continue . . .
4
  • Also, fix your code indentiations Commented Oct 10, 2017 at 17:40
  • Yes, because on the first line you did input=input(...). Now the variable input refers to whatever string was returned by the input function, which is now shadowed and inaccessible. Commented Oct 10, 2017 at 17:41
  • Changed the variable and it's working. Thank you. Commented Oct 10, 2017 at 18:28
  • Code is not working properly, pls can you help me fixing it. Commented Oct 10, 2017 at 18:37

2 Answers 2

2

Don't call the name of your variable the same as the function input

Sign up to request clarification or add additional context in comments.

Comments

0

Looked at your code. Not quite get the purpose of your first line:

input=input("select the garment you purchased type 1 for shirt, 2 for pants, 3 for coats: ")

That could overwrite the input() function with whatever string you type in the command line. As a result, the later function call input() goes with that string, which is not a function, and not callable.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.