how do i write a code in python that compares two strings A and B such that it will print ‘true’ if ALL the letters in A are in B but print ‘false’ if not. ( note the two strings may not be of equal lengths) i tried using the for loop but it only test the first letter of A
A=”
B=”
for c in A:
if c not in B:
print(‘False’)
else:
print(‘True’)
>Solution :
You can convert your string to set():
A = "fedca"
B = "abcdefg"
if set(A) <= set(B):
print("All the letters of A are contained in B")