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 6186405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:53:02+00:00 2026-05-24T01:53:02+00:00

I am new to python and I am trying to create a capitalize function

  • 0

I am new to python and I am trying to create a capitalize function that either capitalizes all words in a string or only the first word. Here is my function

def capitalize(data, applyToAll=False):
    """depending on applyToAll it either capitalizes
       all the words in the string or the first word of a string"""

    if(type(data).__name__ == "str"):

        wordList = data.split()

        if(applyToAll == True):

            for word in wordList:
                wordList[word] = word.capitalize() #here I am stuck!

            return " ".join(wordList)

        else: return data.capitalize()

    else: return data

So basically, I want to edit the item but I don’t know how I can do it.

Btw, this is an optional question: in c# I had the chance to debug my code, what do yo guys use in python to debug?

  • 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-05-24T01:53:03+00:00Added an answer on May 24, 2026 at 1:53 am

    Use a list comprehension:

    def capitalize(s, applyToAll=False):
        if applyToAll:
            l = [w.capitalize() for w in s.split()]
            return " ".join(l)
        else:
            return s.capitalize()
    

    what do yo guys use in python to debug?

    print statements for complicated pieces of code, the interactive interpreter for anything else. I write a lot of tests through, and run them with nose.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to python and I'm trying to create a program that creates
I am very new to Python, and trying to figure out how to create
I am trying to create a python script that opens a single page at
I'm very new to python (just started yesterday), and I'm trying to create permutations
I'm trying to create an environment using virtualenv. virtualenv test New python executable in
I'm new to Python and I'm trying to create a simple GUI using Tkinter.
I am trying create a new frame in wxPython that is a child of
I was trying to create an 2d list in python that was x +
I am trying to create a python script that adds quotations around part of
Im new two python and am trying to grow a dictionary of dictionaries. I

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.