python else statement syntax error -


When I run it, I get the following error: Does anyone know what this can be? The purpose of this program is to create an array, remove all punctuation marks from the array and remove all lowercase letters from the array

file "words.py", line 37 and: ^ syntax error: invalid syntax < Import import system from scanner import * arr = [] def main (): Print ("program name", sys.argv [0]] / P>

shell1

  ) For the range (1, lane (sys.argv), 1): print ("logic", "," is, sys.argv [i]) token = readTokens ("text.txt") cleanTokens = (token ! = ""): Arr.append (token) token = "" "=" "" = "" " = "String = ARR [i] clear =" "punctuation marks =" "=" "=" "==" ======================== ================================================== = ""! "# $% & Amp; () * +, - / / ;; & Lt; = & Gt; ([0, lane (string)), 1): [string] [i] not in punctuation: clear + = string [i] result .append (@ 0, lane (string)) in the range for @ [\] ^ _ {{}} ~ "" Clear (printed) Return results (result) DEA decapitalizeTokens (results): If (ord (results) & lt; = ord ('Z')): Return CHR Ord (result) + ord ('a') - (ord (' A ')) Other: Return results main ()  

Edit:

You are already returning results to deleted token , so it should be in the main Tax :

  cleanTokens = depunctuateTokens (arr) words = decapitalizeTokens (cleantocaine)  


You need a closing bracket:

  return chr (ord (result) + ord ('a') - (ord ('a')) # here - ^  

Or, you Extra opening brackets can be removed:

  return chr (ord (result) + ord ('a') - (ord ('a')) # here - ^  < / Pre> 

Personally, I will re-scan to improve the next solution You should only use the parentheses if:

  1. Syntax You are required to.

  2. This will clearly improve the clarity of code.

Otherwise, they are just unnecessary characters.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -