Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Each time you go through the
list and print a word you print one more uppercase letter than the previous word. Your
output should look like this:
The
DEad
PARrot
SKETch

What I have tried:

Many times but it only print first letter of word
Python
list = ["the","dead","parrot","sketch"]
element = 0
for i in list:
      print list [].title()
      element += 1
Posted
Updated 6-Oct-21 19:52pm
v2

1 solution

If your code ran at all, it would be more believable, but since it has two syntax errors on the same line ...
Change it to this:
print (list [element].title())
And it'll actually do something. Not what your teacher wants, but something.

Then you can start to make it do the actual task.
title will not do what you want: it always returns a new string with the first character in uppercase, and all the others in lowercase. To increase the number of uppercase characters in a word, you will have to do that manually, there is no built in function for that.

Go back to your course notes for your last lesson, and see what they say - almost certainly you teacher covered this in that lesson!
 
Share this answer
 
Comments
CPallini 7-Oct-21 2:17am    
5.
Richard MacCutchan 7-Oct-21 6:04am    
The outer parentheses are not required in v2 of Python.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900