repl.it
@charles2588/

LongestSubString

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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))
?