Search code examples
pythonwlst

while loop in python gives syntax error


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

Solution

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