logo codesdope

i cannot use increment operator it showing the error..!!

   Stanley Joseph

CODE:

a=1
while a<4:
    print "Hello world"
    a ++

-------------------------

root@kali:~# python2 1.py
  File "1.py", line 4
    a ++
       ^
SyntaxError: invalid syntax
root@kali:~#

 


Answers

  •    Hervy Cloud

    while a<4:
    Let me explain what it does, You used a while loop with a condition (While A is less than 4), A  is 1 and less than 4.

    Use this,
    while a > 4:
        print "Hello world"
        a++



Write your answer
Close

Welcome.please sign up.

Close

Welcome.please login.