Python Forum
Capitalizing a character at a time program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Capitalizing a character at a time program
#1
Hi
I want to create a program to capitalize each character of a sentence for one second and then move to the next.
For example: "hello brian"
First H should be capitalized for one second and then e and then l and so on.
I think it is good for learning Python
Can anyone help?
Reply
#2
You're right, it's a good exercise, so what you've done so far.
Reply
#3
Hello,
yes it sounds like a fun way to tinker with Python. Have you already learned about loops?
You can solve the task in quite a simple way by using a loop, time.sleep and string upper() method.
Reply
#4
Yeah, I know loops and time.sleep.
But I don't know how to put it all together.
Reply
#5
Give it a try and let's continue from there.
Which python tutorial do you use btw?
Reply
#6
Hello!
See string.capwords() method.

>>> import string
>>> s = "hello brian"
>>> string.capwords(s)
'Hello Brian'
>>> 
Aaaa, sorry! You want to capitalize each character in the string. Ignore this snipped
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#7
So far I have tried this:


Quote:text = "Welcome to my Program"

for a in text:
    print(a)


It shows the contents of the file in a vertical format.
Reply
#8
(Jan-27-2017, 12:23 AM)wavic Wrote: Hello!
See string.capwords() method.

>>> import string
>>> s = "hello brian"
>>> string.capwords(s)
'Hello Brian'
>>> 
Aaaa, sorry! You want to capitalize each character in the string. Ignore this snipped

If this was the expected outcome from the OP, you could of just used the title method since a string is in of itself an object.
>>> "hello brian".title()
'Hello Brian'
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [solved] unexpected character after line continuation character paul18fr 4 3,296 Jun-22-2021, 03:22 PM
Last Post: deanhystad
  SyntaxError: unexpected character after line continuation character siteshkumar 2 3,111 Jul-13-2020, 07:05 PM
Last Post: snippsat
  Program to keep track of reading time test 3 2,407 Apr-08-2020, 08:38 AM
Last Post: snippsat
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 2,675 Jan-05-2020, 11:50 AM
Last Post: vivekagrey
  Replace changing string including uppercase character with lowercase character silfer 11 6,077 Mar-25-2019, 12:54 PM
Last Post: silfer
  Hard time trying to have clean MySQL to CSV program PierreSoulier 2 2,732 Jul-20-2018, 07:52 AM
Last Post: PierreSoulier
  SyntaxError: unexpected character after line continuation character Saka 2 18,476 Sep-26-2017, 09:34 AM
Last Post: Saka

Forum Jump:

User Panel Messages

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