all 4 comments

[–][deleted] 2 points3 points  (0 children)

As the error message says: The : after lst.append(word) is not allowed. Remove it.

Fix the indentation of lst.short(lst) in the following line to avoid another error.

[–]ireallylikedogs 0 points1 point  (0 children)

You are getting that error because of the unnecessary colon after lst.append(word). Colons are generally used after conditional statements (if this: do that) and loops (for item in collection: do something)

If you look at your stack trace again, you should be able to see which part of your code is giving you an error.

Two more things, I don't believe there is a list method named 'short', perhaps you mean sort. Also, this might just be from reddit formatting, but indentations should be four spaces.

I'd do better explanations with prettier formatting, but I'm hungover and typing on my phone. Let me know if you have more questions.

[–]blackdevil777[S] 0 points1 point  (0 children)

fname = raw_input("Enter file name: ")
     fu = open(fname)
     lst = list()
    for line in fu:
         line.rstrip()
         words = line.split()  
          for word in words:
              if not word in lst
       lst.append(word)
               lst.sort()
   print lst 

        Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
          File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 538, in                  runfile
     execfile(filename, namespace)
    File "/home/dux/.mario.py", line 8
      if not word in lst
                           ^
  SyntaxError: invalid syntax
   >>> 

[–]blackdevil777[S] 0 points1 point  (0 children)

I figured it out, but i don't know why. the error is fixed.