word1 = input()
word2 = input()
a = len(word2)
b = len(word1)
count = b
while (word2[a-1] == word1[b-1]):
count-=1
a -= 1
if count == 0:
break
else:
print('it cant be made')
b-=1
print('it can be made')
What I am trying to do is compare the last letter of word2 to the last letter of word 1 and if they are equal, - the count by 1 and move down a letter in word 2 until the count is == to 0 therefore suggesting the word can be made. if the 2 letters aren't equal it should just move onto the next letter of word1 and repeat the process. if the the count doesn't reach 0 then the word can't be made because it is the Len of the word you are trying to make.
Aucun commentaire:
Enregistrer un commentaire