hello,

well, i have to say that you've at least made a good start at a solution.
right now you're thinking about it very much like a human. try to put
yourself into the shoes of a computer: how can we solve this task for just
ONE name?

once you have that solution, then you can apply the same solution for all
names by looping over or iterating through them. in your solution, you
tried to do everything at once using brute force.

i recommend you take the lessons learned you borrow some of that code and
solve it for a single name. for example, take a look at this pseudocode:

name = 'Guido'
if name first letter == name last letter: # turn this into real Python
using what you have
    print 'match'
else:
    print 'not a match'

then add the collection and a loop, and you'll be at your solution!

best of luck!
--wesley


On Fri, Sep 27, 2013 at 10:04 AM, Jacqueline Canales <jackiexxd...@gmail.com
> wrote:

> composers = ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen']
> x = 'Antheil'
> s = 'Saint-Saens'
> h = 'Beethoven'
> y = 'Easdale'
> k = 'Nielsen'
>
> if s[0] == 'S' or s[0] == 's' == s[-1] == 'S' or s[-1] == 's':
>     if y[0] == 'E' or y[0] == 'e' == y[-1] == 'E' or y[-1] == 'e':
>         if k[0] == 'N' or k[0] == 'n' == k[-1] == 'N' or k[-1] == 'n':
>             print(s,k,y)
>         else:
>             print(" ")
>
> ####Answer i Got Below
> >>>
> Saint-Saens Nielsen Easdale
> >>>
>
> Is this what i was going for in the direction i was a bit confused if we
> were suppose create loops or if statements that are verified in the actual
> composers list. I don't know i feel as if i know what i need to do i just
> cant put it together.
>
>
> On Fri, Sep 27, 2013 at 3:14 AM, 罗彭 <luopeng...@gmail.com> wrote:
>
>> Maybe the length of each name matters, too. You should consider whether
>> to skip null('') and single-character('a').
>>
>>
>> On Fri, Sep 27, 2013 at 3:57 PM, Dharmit Shah <shahdhar...@gmail.com>wrote:
>>
>>> Also, comparison is case sensitive. Meaning, 'A' and 'a' are not the
>>> same.
>>>
>>> Hope that helps. :)
>>>
>>> On Fri, Sep 27, 2013 at 1:14 PM, Amit Saha <amitsaha...@gmail.com>
>>> wrote:
>>> > On Fri, Sep 27, 2013 at 3:48 PM, Jacqueline Canales
>>> > <jackiexxd...@gmail.com> wrote:
>>> >> So I have been trying to do this program using ifs and or loops.
>>> >> I am having a hard time solving this question, If you could please
>>> assist me
>>> >> in the right direction.
>>> >>
>>> >> Write a program that lists all the composers on the list ['Antheil',
>>> >> 'Saint-Saens', 'Beethoven', 'Easdale', 'Nielsen'] whose name starts
>>> and ends
>>> >> with the same letter (so Nielsen gets lsited, but Antheil doesn't).
>>> >>
>>> >> I know below it prints the entire list of composers but i dont know
>>>  how to
>>> >> do the program above. I think I am thinking to much into but ive
>>> looked at
>>> >> all my notes and online resources and having a hard time coming up
>>> with
>>> >> anything.
>>> >> Please help!
>>> >>
>>> >> composers = ['Antheil', 'Saint-Saens', 'Beethoven', 'Easdale',
>>> 'Nielsen']
>>> >> for person in composers:
>>> >>     print(person)
>>> >
>>> > So, here you are printing every compose as you rightly state above.
>>> > What you now need to do is:
>>> >
>>> > For each of the composers (`person'), you need to check if the first
>>> > letter and the last letter are the same. Here;s a hint:
>>> >
>>> >>>> s='abba'
>>> >
>>> > The first letter:
>>> >
>>> >>>> s[0]
>>> > 'a'
>>> >
>>> > The last letter:
>>> >
>>> >>>> s[-1]
>>> > 'a'
>>> >
>>> >
>>> > If you now compare these, you will know if they are the same and hence
>>> > you print him/her.
>>> >
>>> > Hope that helps.
>>> > -Amit
>>>
>>
-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A computer never does what you want... only what you tell it."
    +wesley chun <http://google.com/+WesleyChun> : wescpy at gmail :
@wescpy<http://twitter.com/wescpy>
    Python training & consulting : http://CyberwebConsulting.com
    "Core Python" books : http://CorePython.com
    Python blog: http://wescpy.blogspot.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to