Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Clean Employee Name List | Automating HR Workflows
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for HR Specialists

bookChallenge: Clean Employee Name List

Before you begin automating the cleaning of employee name lists, it is important to recall some useful string methods in Python. When dealing with inconsistent capitalization and unwanted spaces in names, you can use the strip() method to remove leading and trailing spaces, and the title() method to ensure each word in the name is properly capitalized.

123
name = " jAnE doE " cleaned_name = name.strip().title() print(cleaned_name) # Output: Jane Doe
copy

To process a list of employee names, you should apply both strip() and title() to each item in the list. This will ensure that every name is formatted consistently, making your HR records cleaner and easier to use in automated workflows.

Oppgave

Swipe to start coding

Write a function that takes a list of employee names and returns a new list where each name has no leading or trailing spaces and is properly capitalized.

  • For each name in the input list, remove any leading or trailing spaces.
  • Capitalize each word in the name so that only the first letter of each word is uppercase.
  • Return the cleaned list of names.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 5
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Suggested prompts:

How can I apply these methods to a whole list of names?

Can you explain what the `title()` method does in more detail?

Are there other useful string methods for cleaning names?

close

bookChallenge: Clean Employee Name List

Sveip for å vise menyen

Before you begin automating the cleaning of employee name lists, it is important to recall some useful string methods in Python. When dealing with inconsistent capitalization and unwanted spaces in names, you can use the strip() method to remove leading and trailing spaces, and the title() method to ensure each word in the name is properly capitalized.

123
name = " jAnE doE " cleaned_name = name.strip().title() print(cleaned_name) # Output: Jane Doe
copy

To process a list of employee names, you should apply both strip() and title() to each item in the list. This will ensure that every name is formatted consistently, making your HR records cleaner and easier to use in automated workflows.

Oppgave

Swipe to start coding

Write a function that takes a list of employee names and returns a new list where each name has no leading or trailing spaces and is properly capitalized.

  • For each name in the input list, remove any leading or trailing spaces.
  • Capitalize each word in the name so that only the first letter of each word is uppercase.
  • Return the cleaned list of names.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 5
single

single

some-alt