inputs
stringlengths 50
14k
| targets
stringlengths 4
655k
|
|---|---|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
pass
s = pow(n,2)
return s
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
res = n*n
return res
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
a = n ** 2
return a
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
return n**2
print(square(5))
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
squared = n * n
return squared
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
return n**2 #self explanatory
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
answer = n*n
return answer
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
sqr = n ** 2
print sqr
return sqr
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
s = n*n
return s
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
ans = 0
for i in range(n):
for j in range(n):
ans += 1
return ans
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
import math
return math.pow(n, 2)
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
i = n * n
return i
pass
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
result = n ** 2
return result
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
a=n*n
return a
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
square = n ** 2
return square
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
'''return the square of number'''
return n ** 2
|
Now you have to write a function that takes an argument and returns the square of it.
|
import math
def square(n):
return n**(math.sqrt(4))
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
"""This function return square of number"""
return n * n
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
return n * sum([1 for x in range(0, n)])
|
Now you have to write a function that takes an argument and returns the square of it.
|
import math
def __pow(a, b=2):
return pow(a, b)
math.pow = __pow
square = math.pow
|
Now you have to write a function that takes an argument and returns the square of it.
|
square = lambda n: pow(n, 2)
|
Now you have to write a function that takes an argument and returns the square of it.
|
square = lambda a:a**2
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
n = n * n
return n
|
Now you have to write a function that takes an argument and returns the square of it.
|
import math
def square(n):
return n**2
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
return abs(n*n)
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n,y=2):
if y == 1:
return n
else:
return n * square(n, y - 1)
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
sqr = n ** 2
return sqr
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
return int(n**2)
|
Now you have to write a function that takes an argument and returns the square of it.
|
import math
def square(n):
return n*n
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
sq = n**2
return sq
pass
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
if type(n) == int or type(n) == float:
return n**2
else:
return False
|
Now you have to write a function that takes an argument and returns the square of it.
|
square=lambda x:x**2
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
n = n **2
return n
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
ans = n**2
return ans
|
Now you have to write a function that takes an argument and returns the square of it.
|
square = lambda x: x*x
|
Now you have to write a function that takes an argument and returns the square of it.
|
def square(n):
return float(n)*n
|
Now you have to write a function that takes an argument and returns the square of it.
|
from math import pow
def square(n):
return pow(n,2)
|
Now you have to write a function that takes an argument and returns the square of it.
|
#def square(n):
# pass
square = lambda n: n**2
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
def hollow_triangle(n):
width = n * 2 - 1
row = '{{:_^{}}}'.format(width).format
return [row(mid(a)) for a in xrange(1, width, 2)] + [width * '#']
def mid(n):
return '#' if n == 1 else '#{}#'.format('_' * (n - 2))
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
def hollow_triangle(n):
w, result = 2 * n - 1, [f"{'_' * (2*i-1):#^{2*i+1}}" for i in range(n - 1)]
return [f"{l:_^{w}}" for l in result] + ["#" * w]
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
hollow_triangle=lambda n:["".join([['_','#'][k in[n-1-i,n-1+i]]for k in range(n*2-1)])for i in range(n-1)]+[f"{'#'*(n*2-1)}"]
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
def hollow_triangle(n):
return [(f'#{"_" * (2*i-1)}#' if i else '#').center(2*n-1, '_') for i in range(n-1)] + ['#' * (2*n-1)]
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
def hollow_triangle(n):
return ['_' * (n - i - 1) + '#' + '_' * (2 * i - 1) + '#' * (i >= 1) + '_' * (n - i - 1) \
for i in range(n - 1)] + ['#' * (2 * n - 1)]
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
def hollow_triangle(n):
if n == 1:
return ['#']
first = ["_"*(n-1)+"#"+"_"*(n-1)]
last = ["#"*(2*n-1)]
return first +["_"*(n-i-1)+"#"+"_"*(2*i-1)+"#"+"_"*(n-i-1) for i in range(1,n-1)] + last
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
def hollow_triangle(n):
total_width = 2 * n - 1
triangle = ['#'.center(total_width, '_')]
for i in range(1, total_width-2, 2):
triangle.append('#{}#'.format('_' * i).center(total_width, '_'))
triangle.append('#' * total_width)
return triangle
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
m,hollow_triangle=lambda s:s[:0:-1]+s,lambda n:[m('_'*i+'#'+'_'*(n-i-1))for i in range(n-1)]+[m(n*'#')]
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
def hollow_triangle(n):
lines = ['_' * (n-i-1) + '#' + '_' * (2*i-1) + '#' + '_' * (n-i-1) for i in range(1, n-1)]
return ['_' * (n-1) + '#' + '_' * (n-1)] + lines + ['#' * (2*n-1)] if n > 1 else ['#']
|
Create a function hollow_triangle(height) that returns a hollow triangle of the correct height. The height is passed through to the function and the function should return a list containing each line of the hollow triangle.
```
hollow_triangle(6) should return : ['_____#_____', '____#_#____', '___#___#___', '__#_____#__', '_#_______#_', '###########']
hollow_triangle(9) should return : ['________#________', '_______#_#_______', '______#___#______', '_____#_____#_____', '____#_______#____', '___#_________#___', '__#___________#__', '_#_____________#_', '#################']
```
The final idea is for the hollow triangle is to look like this if you decide to print each element of the list:
```
hollow_triangle(6) will result in:
_____#_____ 1
____#_#____ 2
___#___#___ 3
__#_____#__ 4
_#_______#_ 5
########### 6 ---- Final Height
hollow_triangle(9) will result in:
________#________ 1
_______#_#_______ 2
______#___#______ 3
_____#_____#_____ 4
____#_______#____ 5
___#_________#___ 6
__#___________#__ 7
_#_____________#_ 8
################# 9 ---- Final Height
```
Pad spaces with underscores i.e _ so each line is the same length.Goodluck and have fun coding !
|
def hollow_triangle(n):
ans = []
for i in range(n-1, 0, -1):
x = '_' * i + '#' + '_' * (n-i-1)
ans.append(x[:-1] + x[::-1])
return ans + ['#' * (2*n - 1)]
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
return string.endswith(ending)
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
solution = str.endswith
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
return ending in string[-len(ending):]
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
# your code here...
string1 = len(string) - len(ending)
string2 = len(string) - string1
string3 = string[string1:]
if string3 == ending:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
solution=str.endswith
# Easy peasy
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
# your code here...
return ending == string[len(string)-len(ending):]
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(a,b):
return(a.endswith(b))
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
solution = lambda string, ending: string.endswith(ending)
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if ending in string:
if ending == '':
return True
else:
str1Arr = string.split(f'{ending}')
if str1Arr[-1] == '':
return True
else:
return False
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
pass
sol = string.endswith(ending)
return sol
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if string.endswith(ending):
return True
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if ending in string[-len(ending):]:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
return string[len(string)-len(ending):len(string)] == ending
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if len(ending) > len(string):
return False
if len(ending) == 0:
return True
else:
# try
ending = ending[::-1]
string = string[::-1]
#ll = -1 * len(ending)
#string = string[ll:]
for i in range(len(ending)):
if i > len(string)-1:
break
if ending[i] == string[i]:
continue
else:
return False
return True
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if string.endswith(ending):
return True
else:
return False
print(solution('abc','bc'))
print(solution('abc','d'))
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if ending not in string or len(ending) > 0 and string[-1] != ending[-1]:
return False
else:
return True
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
f=len(ending)
h=[i for i in ending]
r=[]
for i in string:
r.append(i)
r =(r[-f:])
if r == h:
return True
elif h == []:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if len(ending) > len(string):
return False
elif ending =='':
return True
else:
for x,y in zip(string[::-1], ending[::-1]):
if x!=y:
return False
return True
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
return True if ending == "" else ending == string[-1*len(ending):]
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
solution = lambda s,e: not e or s[-len(e):] == e
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
from re import search, escape
def solution(string, ending):
return bool(search(escape(ending)+'\Z',string))
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
return string[len(ending)*-1:] == ending or ending == ''
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
length = len(ending)
if string[len(string) - length:] == ending:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
List1 = []
while True:
if len(string) == 0:
return False
if string == ending:
return True
break
else:
string = string[1:]
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
# your code here...
if(len(ending) == 0):
return True
if(len(string) == 0):
return False
last1 = string[-1]
last2 = ending[-1]
if(last1 == last2):
return True and solution(string[:-1],ending[:-1])
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
l_ending = -(len(ending))
if l_ending == 0:
return True
elif string[l_ending:] == ending:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
comparison = string[-len(ending):]
if len(ending) == 0:
return True
if comparison == ending:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
ns = len(string)
ne = len(ending)
if(ne == 0):
return True
else:
if(string[-ne::] == ending):
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
remove = len(string) - len(ending)
return string[remove:] == ending
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(str, ending):
if len(ending) == 0 or ending == str[-len(ending):]:
return True
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(str, end):
str = str[::-1]
end = end[::-1]
end_length = len(end)
str_length = len(str)
result = 0
if(end_length > str_length):
return False
else:
for i in range(end_length):
if(str[i] == end[i]):
result +=1
if(result == end_length):
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if ending == "" or string[-int(len(ending)):] == ending:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
"""Standalone solution."""
ending_length = len(ending)
if ending_length == 0:
return True
return string[-ending_length:] == ending
def solution_endswith(string, ending):
"""Proper solution using `endswith()`."""
return string.endswith(ending)
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
# your code here...
#string = "abc"
#ending = "bc"
return string.endswith(ending)
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
size = len(ending)
if string[-size:] == ending or ending == '':
return True
else:
return False
pass
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
e_len = len(ending)
s_len = len(string)
if e_len == 0:
return True
elif (s_len >= e_len) and (string[-e_len:] == ending):
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if ending == string[-len(ending):len(string)] or ending == '':
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if ending is "" : return True
ln = len(ending)
string = string[::-1]
str = string[:ln]
return str[::-1] == ending
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
var = string.find(ending, (len(string)-len(ending)), (len(string)))
if var == -1:
return False
else:
return True
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
a=(string.find(ending,len(string)-len(ending)))
if a != -1:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if len(ending) > len(string):
return False
out = True
inc = 0
revString = string[::-1]
for i in ending[::-1]:
if i != revString[inc]:
out = False
inc = inc + 1
return out
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
str_len = len(string)
end_len = len(ending)
return str_len >= end_len and string[str_len - end_len:] == ending
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
start = -len(ending)
return True if start == 0 else string[start::] == ending
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
numbs = len(ending)
if numbs == 0:
return True
elif string[-numbs:] == ending:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
newEnding = ending[::-1]
newString = string[::-1]
stringCount = 0
print (newString, newEnding)
for letters in newEnding:
if stringCount < len(newString):
print (stringCount)
if letters != newString[stringCount]:
return False
stringCount += 1
else:
return False
return True
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
retval = False
if string.endswith(ending):
return True
return retval
pass
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
index = string.rfind(ending)
if (index == len(string) - len(ending) or not ending) and index >= 0: return True
else: return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
print(string[-1 * len(ending): None: 1])
if ending == '':
return True
if ending == string[-1 * len(ending): None: 1]:
return True
else:
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
for x in range(0,len(string)+1):
if string[x:len(string)]==ending:
return True
return False
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
# your code here...
end_len=len(ending)
str_len=len(string)
actualend=string[str_len-end_len:]
if actualend==ending:
return(True)
else:
return(False)
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
if ending not in string:
return False
for a,b in zip(string[::-1],ending[::-1]):
if a!=b:
return False
return True
|
Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
Examples:
```python
solution('abc', 'bc') # returns true
solution('abc', 'd') # returns false
```
|
def solution(string, ending):
return (True if ending == '' or string[-1 * len(ending):] == ending else False)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.