Very new and beginner to python, got a small assignment to do this
Suppose that you have a list of strings named samples.
Write a Python loop that goes through the list and counts the number of strings where the string length is 2 or more and
the first and last characters of the strings are the same.
Test your code on the following three versions of the list samples:
samples = ['aba', 'xyz', 'aa', 'x', 'bbb']
samples = ['', 'x', 'xy', 'xyx', 'xx']
samples = ['aaa', 'be', 'abc', 'hello']
What i tried did not work it returned nothing for me
samples=['aba', 'xyz','aa', 'x', 'bbb']
for elem in samples:
if ( len(elem) >=2 and str.startswith('"') and str.endswith('"')):