fork download
  1. def do(operations):
  2. result = 0
  3. length = len(operations)
  4. list_i = list(range(0,length))
  5. for i in list_i :
  6. if(operations[i]=="--"):
  7. result -= 1
  8. elif(operations[i]=="++"):
  9. result += 1
  10. return result
  11.  
  12.  
  13. experession_list = eval(input()) #if input as a list like this : "++", "++", "--", "++" or ["++", "++", "--", "++"]
  14. """experession_list = input().split()""" #if input spaced like this : ++ ++ -- ++
  15.  
  16. result = do(experession_list)
  17. print(result)
  18.  
  19.  
Success #stdin #stdout 0.02s 9600KB
stdin
["++", "++", "--", "++"]
stdout
2