Define a function that takes a string and an integer, word and n, and returns character of word with index n + 1.
Write a function that takes one string with more than 10 characters, and returns
its fifth to eighth (not including eighth) characters. Example:
>>> middle('programming')
'ram'
Write a function that takes one string, and returns True if "a" appears in the string. It returns False otherwise.
Define a function count_shared_letters(word1, word2) that returns the number of letters from word1 that are found in word2.
Define a function, fifth_from_end(word), that returns word's fifth character from the end.
Write a function that takes two values and returns True if they are equal, or False otherwise.
Write a function, that takes a word and a character,
word and char, and returns the index of char where it appears in word.
If there are more than one char, it should return the last index.
Example:
>>> last('ani', 'n')
1
>>> last('nana', 'n')
2
>>> last('nana', 'a')
3
Restrictions: You cannot use +, - or ==
def return_char(s, n):
index = len(s) - n
return s[index]
Given the above script, what are the results of the following expressions:
| return_char("python", 1): | ||
| return_char("python", 3): |
def return_char(s, n):
return s[n]
Given the above script, what are the results of the following expressions:
| return_char('zanatek', -1): | ||
| return_char('zanatek', -4): |
Complete execution flow of the following program
>>>
Complete execution flow of the following program
def dosmth(s, i): index = 0 while index < len(s): if index == i: return s[i] index = index + 1 dosmth('pst', 1)