Close
Close

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

  •   

    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++



Ask Yours
Post Yours
Write your answer