Python Forum
Changing small letter.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing small letter.
#1
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.
Reply
#2
changing
yield i.capitalizate()
to
yield i.capitalize()
will improve the code
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020