Programming Questions

  • Newest
  • Popular Tags
  • Ask Question
  • Solution seems correct - Simple Symbols Python
    My code is above. For some reason coderbyte is giving me 0 points and saying I failed all test cases, but when I input them manually I'm getting all right answers. Help? def SimpleSymbols(string): if string[0].isalpha() or string[-1].isalpha(): return False for i in range(1,len(string)-1): if string[i].isalpha(): if string[i-1] != '+': return False if string[i+1] != '+': return False return True # keep this function call here # to see how to enter arguments in Python scroll down print SimpleSymbols(raw_input())
    camsbury posted this question on 1/5/16 | simple, symbols, python
    Answers
  • +
  • 2
  • -
  • You need to return the strings "true" or "false," not Python's True or False. Change it to: def SimpleSymbols(string): if string[0].isalpha() or string[-1].isalpha(): return "false" for i in range(1,len(string)-1): if string[i].isalpha(): if string[i-1] != '+': return "false" if string[i+1] != '+': return "false" return "true" # keep this function call here # to see how to enter arguments in Python scroll down print SimpleSymbols(raw_input())
    Log in to write an answer.