[Tutor] List Python Question..Please help

罗彭 luopeng.he at gmail.com
Fri Sep 27 10:14:45 CEST 2013


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 <shahdharmit at 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.in at gmail.com> wrote:
> > On Fri, Sep 27, 2013 at 3:48 PM, Jacqueline Canales
> > <jackiexxduh3 at 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.
> >
> >
> > --
> > http://echorand.me
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
>
>
>
> --
> Dharmit Shah
> www.about.me/dharmit
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130927/71932387/attachment-0001.html>


More information about the Tutor mailing list