Python Forum
Changing small letter. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Changing small letter. (/thread-17296.html)



Changing small letter. - pawlo392 - Apr-05-2019

I want to write generator, which will be change the first letter of the names from list. I have to use "for" and "yield". I thought about something like that:
def names(lis):
    for i in lis:
        yield i.capitalizate()
for Names in names(['john','tom','bruce']):
    print(Names)
But I don't have idea hot to improve this code.


RE: Changing small letter. - Yoriz - Apr-05-2019

changing
yield i.capitalizate()
to
yield i.capitalize()
will improve the code