myList = [12, 8, 9, 3, 4, 14, -1, 56, 43] # assign first element to variable my_max = myList[0] # loop through the list for number in myList: if my_max < number: my_max = number print my_max # print the last item in the list #print myList[-2] '''This is a very long comment and I am certainly going to need more than just one single line in order to make this comment as clear as possible. Do you understand?''' #print myList[-3] myText = 'This is a very short text.\nIt really only has three lines.\nThis is it, the third line.' lines = myText.split('\n') print lines for line in myText: print line
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