In: Computer Science
What python codes should I use to solve this question below?
Use input() function once to retrieve an input and assign that input value to a variable. Check if the input contains the string “an”. If so, use input() function one more time to retrieve an input and assign the new input value to a different variable. Now, replace “an” characters in the first variable with the first two characters of the second variable if only the second variable has at least two characters
var_1 = input("enter a string here:\t")
if(var_1.find("an") != -1):
var_2 = input("enter another string here:\t")
if(len(var_2) >= 2):
var_1 = var_1.replace("an",
var_2[0:2])
print(var_1)
If you have any doubts please comment and please don't dislike.