diff --git a/isSubstring.py b/isSubstring.py index 5e2c326..54622b3 100644 --- a/isSubstring.py +++ b/isSubstring.py @@ -5,3 +5,11 @@ def isSubstring(s,s1): return True print isSubstring("anumsharma","ar") + +####### Another Method ##### + +def isSubstring(s,s1): + if s.find(s1) != -1: + return True + +print (isSubstring("anumsharma","ar")) diff --git a/removing_the_values_at_index.py b/removing_the_values_at_index.py index a603dfb..c456280 100644 --- a/removing_the_values_at_index.py +++ b/removing_the_values_at_index.py @@ -6,3 +6,11 @@ lists= [12,24,35,70,88,120,155] lists= [x for (i,x) in enumerate(lists) if i not in (0,4,5)] print lists # [24, 35, 70, 155] + +##### Another Method ##### + +list = [12,24,35,70,88,120,155] +indices = {0,4,5} +for index in sorted(indices, reverse=True): + del list[index] +print(list) # [24, 35, 70, 155]