Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:07:24+00:00 2026-06-14T17:07:24+00:00

I am trying to manipulate a word by upper casing each character in an

  • 0

I am trying to manipulate a word by upper casing each character in an array, but when it comes to a word that has two of the same character it makes them both capitalized instead of just one. Not a programmer just trying to learn python. Thank in advance!

answer = raw_input("What is your word? ")
x = 0
answerWord = ''.join(answer)
while (x < len(answer)):
    if (answerWord[x] != answerWord[x].upper()):
        letter = answerWord.replace(answer[x], answer[x].upper())
    print letter
    x = x + 1

What is your word? boot
Boot
bOOt
bOOt
booT

What is your word? crazy
Crazy
cRazy
crAzy
craZy
crazY
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:07:25+00:00Added an answer on June 14, 2026 at 5:07 pm
    answer = raw_input("What is your word? ")
    
    for char in range(len(answer)):
        letter = answer[0:char] + answer[char].upper() + answer[char+1:]
        print letter
    

    That should do the thing, it changes every letter to upper case one by one, and then prints them. Also, in your example, if you take a word that already has uppercase letters (‘Peanuts’, for example) it will raise an error, since the the “if” sentence is not True, and therefore letter would be undefined.

    If you want uppercase letters to go lowercase, and lowercase letters to go uppercase, or such, use this:

    answer = raw_input("What is your word? ")
    
    for char in range(len(answer)):
        if answer[char] == answer[char].lower():
            letter = answer[0:char] + answer[char].upper() + answer[char+1:]
        else:
            letter = answer[0:char] + answer[char].lower() + answer[char+1:]
        print letter
    

    Also note, that if you’re not going to use letter for anything other than printing it, you could just replace both of the letter definitions with simply a print, and remove the print letter completely.

    if answer[char] == answer[char].lower():
        print answer[0:char] + answer[char].upper() + answer[char+1:]
    else:
        print answer[0:char] + answer[char].lower() + answer[char+1:]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to manipulate an array that I call from a PHP file.
question 1: i am trying to manipulate same classed div element's css to their
I have a global variable averagel that I am trying to manipulate in a
I'm trying to follow this tutorial to made a Word doc template that i
I'm trying to manipulate two elements within a jquery function and i'm not seeing
I am working on some code that has to manipulate unicode strings. I am
I am trying to manipulate a string so that any quotes () within <a
I'm trying to manipulate an id to use the same button to do more
I'm trying to manipulate a PHP script so that it redirects to a particular
Hey guys I am trying to manipulate a word .docx file using the openXML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.