Created
June 28, 2016 05:47
-
-
Save charles2588/d5d3facc1d98229245bb8d6ad25e937e to your computer and use it in GitHub Desktop.
https://repl.it/C6Vc/1 created by charles2588
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def goo_longestsubstring(str,dictionary): | |
longest=0 | |
longeststr="" | |
for k,v in dictionary.items(): | |
if v in str: | |
if longest<len(v): | |
longest=len(v) | |
longeststr=v | |
return longeststr | |
dictionary={0:"i",1:"charles",2:"am",3:"gomes",4:"substitute",5:"subcharlessubstitute"} | |
print(goo_longestsubstring("sub",dictionary)) | |
print(goo_longestsubstring("subcharles",dictionary)) | |
print(goo_longestsubstring("subsubstitute",dictionary)) | |
print(goo_longestsubstring("subcharlessubstitute",dictionary)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Python 3.5.1 (default, Dec 2015, 13:05:11) | |
[GCC 4.8.2] on linux | |
>>> | |
charles | |
substitute | |
subcharlessubstitute | |
=> None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment