Write a function which takes a string, s, as argument, and prints its characters with odd index (1, 3, 5, ...) each in a new line.
Define a function count_shared_letters(word1, word2) that returns the number of letters from word1 that are found in word2.
Write a function that takes two strings, and
- if they are equal, it returns "They are equal"
- if they are not equal, it returns "They are not equal"
Write a function, sub, that takes two numbers and returns the first minus the second.
Write a function, that takes a word and an integer,
word and n, and returns the last n characters of word. Example:
>>> get_substring('gegnisht', 2)
ht
>>> get_substring('tosknisht', 4)
isht
Restrictions:
- You cannot use +, - or *
- The body of the function should have only one line
Define a function, shared_letter_string(word1, word2), that returns a new string of characters from word1 that are also in word2, without duplicates, in the order that they appear in word1.
Define a function that takes a string and returns True if its first character is 'b'.
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("zanatek", 2): | ||
| return_char("zanatek", 3): |
def is_char(word, ch, i):
return word[i] == ch
Given the above script, what are the results of the following expressions:
| is_char("llukar", "u", 3): | ||
| is_char("xerxe", "x", 0): | ||
| is_char("carralluke", "c", 1): |
Complete execution flow of the following program
def return_char(s, n): return s[n] return_char('poroj', 2) return_char('mujdin', 1)
Complete execution flow of the following program
def ends_with_the_same_letter(s1, s2): return s1[-1] == s2[-1]