Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

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

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

1 Answer

+1 vote
answered Jun 19, 2020 by Peter Minarik (84,720 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.
...