I tried running a few python codes but they are not giving any output on onlinegdb

0 votes
asked Jun 18 by Mohan (120 points)
def main():
    x = 0
    
    while (x < 5):
        print(x)
        x = x + 1

1 Answer

+1 vote
answered Jun 19 by Peter Minarik (1,950 points)

You have to call main() after you declare it (see last line):

#definition of function main
def main():
    x = 0
    
    while (x < 5):
        print(x)
        x = x + 1

#When the program is called, all the commands get executed (including the ones below)
main()
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...