#while loop: print("#printing using while loop") count=0 while count<10 : if count<5: print("{0} is less than 5".format(count)) elif count==5: print("{0} is equals to 5".format(count)) else: print("{0} is greater than 5".format(count)) count=count+1 #for loop: print("#printing using for loop") hello_list=list() loop_lis=[1,2,3] for i in loop_lis: hello_list.append(i) for i in hello_list: print(i) #method: print("#use of method") def this_is_a_method(param1,param2): return param1+param2 result=this_is_a_method(10,20) print(result)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question