Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions Part-1-Functions
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -38,6 +47,9 @@ def arrayCheck(nums):
# stringBits('Heeololeo') → 'Hello'

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct

def stringBits(str):
return print(str[::2])

stringBits(str)
# CODE GOES HERE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct



Expand All @@ -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)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks only if the the string 1 ends with string 2, What if the str 1 is abc and string 2 is abXabc?

# CODE GOES HERE

#####################
Expand All @@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dude stop using keyword 'str' its an inbuilt keyword, excluding this changes the function is correct



Expand Down Expand Up @@ -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)