<div dir="ltr">Hi,<div><br></div><div>This is a coding challenge in the <a href="https://developers.google.com/edu/python/exercises/basic">Google Developers Python Course</a>. I have been working on this challenge for hours without being able to solve.</div>

<div><br></div><div><div>A. match_ends</div><div># Given a list of strings, return the count of the number of</div><div># strings where the string length is 2 or more and the first</div><div># and last chars of the string are the same.</div>

<div># Note: python does not have a ++ operator, but += works.'</div></div><div><br></div><div>Try #1:</div><div><br></div><div><div>def match_ends(words):</div><div>  numberStrings = [ ]</div><div>  answer = ' '</div>

<div><br></div><div>  for string in words:</div><div>    if len(string) >=2 or string[0] == string[-1]:</div><div>      numberStrings.append(string)</div><div>    else:</div><div>      return ' '</div><div> </div>

<div>  answer = len(numberStrings) </div><div>  print answer</div></div><div><br></div><div><div><br class=""><br></div><div>def match_ends(words):<br></div><div><br></div><div># Calls the above functions with interesting inputs.<br>

</div><div><div>def main():</div><div>  print 'match_ends'</div><div>  test(match_ends(['aba', 'xyz', 'aa', 'x', 'bbb']), 3)</div><div>  test(match_ends(['', 'x', 'xy', 'xyx', 'xx']), 2)</div>

<div>  test(match_ends(['aaa', 'be', 'abc', 'hello']), 1)</div></div></div><div><br></div><div><br></div><div>Tries 2 and on: I wanted to get just the part working to check to see if the first and last character are the same. I tried setting up a for loop within a for loop. The first loop cycles through each word in the list, then the second for loop cycles through each letter to compare if the first character is equal to the last or not. I cannot get it to compare the first and last letter properly.<br>

<br>Help solving this would be very much appreciated!!</div><div><br></div><div>Thank you for the help,</div><div><br></div><div>Adam <br><br><div><br></div><div><br></div><div id="WISESTAMP_SIG_gmail_session"></div></div>

</div>