Aug-08-2020, 08:34 AM
Hello
I am trying to get this function working but cannot work out what is wrong. Any help will be gratefully received. My input is:
My output is:
Thank you
I am trying to get this function working but cannot work out what is wrong. Any help will be gratefully received. My input is:
1 2 3 4 5 6 7 8 9 |
xs = [ "this" , "is" , "a" , "dead" , "parrot" ] def find_first_2_letter_word(xs): for wd in xs: if len (wd) = = 2 : return wd return " " print ( "The first 2 letter word is " , find_first_2_letter_word(xs)) |
Output:Python 3.8.4 (tags/v3.8.4:dfa645a, Jul 13 2020, 16:46:45) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
================== RESTART: C:\Users\John\Desktop\testing1.py ==================
The first 2 letter word is
>>>
As can be seen the program prints the statement but fails to show the first 2 letter word.Thank you