# Assume text is a variable that # holds a string. Write Python code # that prints out the position # of the second occurrence of 'zip' # in text, or -1 if it does not occur # at least twice. # For example, #text = 'all zip files are zipped' # >>> 18 # text = 'all zip files are compressed' # >>> -1 text = "all zip files are compressed" textTWO = "Zip is a file format used for data compression and archiving. A zip file contains one or more files that have been compressed, to reduce file size, or stored as is. The zip file format permits a number of compression algorithms." #ENTER CODE BELOW HERE firstOccurence = text.find('zip') secondOccurence = text.find('zip', firstOccurence + 1) print secondOccurence
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