Learn practical skills, build real-world projects, and advance your career
Created 3 years ago
Question 1:
Given a string of odd length greater 7, return a string made of the middle three chars of a given String
string = 'abcdefghi'
lenght = len(string)
lenght = lenght//2 -1
print(string[lenght:lenght+3])
def
Question 2:
Given 2 strings, s1 and s2, create a new string by appending s2 in the middle of s1
Given: s1 = "Ault", s2 = "Kelly"
AuKellylt
str1 = 'Ault'
str2 = 'Kelly'
l = len(str1)//2
str3 = str1[0:l] + str2 + str1[l::]
str3
'AuKellylt'
Question 3:
Given 2 strings, s1, and s2 return a new string made of the first, middle and last char each input string
Given:
s1 = "America"
s2 = "Japan"
AJrpan