DEV Community

loading...

What will be the output of given code?

lakshyatyagi24 profile image Lakshya Tyagi ・1 min read

Write output of code in comment

i=0
while i<3:
    print(i)
    i++
    print(i+1)
Enter fullscreen mode Exit fullscreen mode

Discussion

pic
Editor guide
Collapse
redhap profile image
HAP
0
2
1
3
2
4
Enter fullscreen mode Exit fullscreen mode
Collapse
thomasmatecki profile image
Thomas Matecki

SyntaxError?

Collapse
jennrmillerdev profile image
Jen Miller

lol I'm not a python developer, but if that's the answer to the question...

Collapse
thomasmatecki profile image
Thomas Matecki

i++ isn't valid syntax in python.

Thread Thread
lakshyatyagi24 profile image
Lakshya Tyagi Author

yes you are correct i++ is not a valid syntax in python

Collapse
promikecoder2020 profile image
ProMikeCoder2020

It will give a error because there are no increment operators in python

Collapse
dibyadarshan8 profile image
Collapse
sambhavjindalgithub profile image
Sambhav-Jindal-github

I think it's not correct