diff --git a/Part-1-Functions b/Part-1-Functions index ba2c387..c946aeb 100644 --- a/Part-1-Functions +++ b/Part-1-Functions @@ -21,6 +21,15 @@ # arrayCheck([1, 1, 2, 1, 2, 3]) → True def arrayCheck(nums): + l=len(nums) + for i in range(l-2): + + if ((nums[i]==1) and (nums[i+1]==2) and (nums[i+2]==3)): + return print("True") + break + else: + i=i+1 + return print("False") # CODE GOES HERE @@ -38,6 +47,9 @@ def arrayCheck(nums): # stringBits('Heeololeo') → 'Hello' def stringBits(str): + return print(str[::2]) + +stringBits(str) # CODE GOES HERE @@ -57,7 +69,23 @@ def stringBits(str): # end_other('abc', 'abXabc') → True -def end_other(a, b): + +str1="abc" +str2="Xaabc" + +def endwith(str1,str2): + str1=str1.lower() + str2=str2.lower() + l1=str1 + l2=str2 + if str1.endswith(l2) or str2.endswith(l1): + print("True") + else: + print("False") + + +endwith(str1,str2) + # CODE GOES HERE ##################### @@ -71,7 +99,13 @@ def end_other(a, b): # doubleChar('AAbb') → 'AAAAbbbb' # doubleChar('Hi-There') → 'HHii--TThheerree' -def doubleChar(str): +def doubleChar(str1): + c = '' + for char in str1: + c = c + char*2 + return print(c) + +doubleChar(str1) # CODE GOES HERE @@ -114,4 +148,10 @@ def fix_teen(n): # count_evens([1, 3, 5]) → 0 def count_evens(nums): - # CODE GOES HERE + +count=0 +for i in nums: + if i%2==0: + count=count+1 +return count +count_evens(nums)