Question

I am very new to python, this is my first program that I am trying. This function reads the password from the standard input.

def getPassword() :
     passwordArray =[]
         while 1:
                 char = sys.stdin.read(1)
                 if char == '\\n':
                         break
                 passwordArray.append(char)
                 return passwordArray

print (username)
print (URL)

getting this error:

Problem invoking WLST - Traceback (innermost last):
  (no code object) at line 0
  File "/scratch/aime/work/stmp/wlstCommand.py", line 10
                 while 1: 
                 ^
SyntaxError: invalid syntax
Was it helpful?

Solution

Your indentation is not correct. Your while should be indented the same as the line above it.

OTHER TIPS

Python uses indentation to "separate" stuff and the thing with that is you need to have the same kind of indentation across the file. Having a fixed kind of indentation in the code you write is good practice. You might want to consider a tab or four spaces(The later being the suggestion in the PEP8 style guide)

Python is sensitive and depended on indentation. If it complains "invalid Format", that is better than "invalid syntax".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top