Python for Data Analytics • Lesson 6

String Methods & Formatting

Learn how to clean, transform, search, split, join and format text using Python string methods and f-strings.

Your progress0%

0 of 8 concepts completed

Complete the activity and related MCQ to unlock the next concept.

Concept 1UPPER / LOWER

Change Case with upper() and lower()

upper() converts every letter to uppercase. lower() converts every letter to lowercase. Both leave numbers and punctuation untouched, and neither changes the original string — they return a new one.

Learn by Seeing

Standardize text case

"python".upper()      # "PYTHON"
"PYTHON".lower()      # "python"

name = "Vista Academy"
print(name.upper())   # VISTA ACADEMY

upper() and lower() always return a new string; the original is unchanged.

Type text and toggle the method — see the live result:

>>> "Vista Academy".upper()

VISTA ACADEMY

Interactive Activity

What is the output of "python".upper()?

Hint: All letters become uppercase.

Python Analyst Mindset

Clean data, then analyze it

Real datasets arrive messy: extra spaces, mixed case, inconsistent separators. String methods are the first pass in any Python analysis — clean the text, then let the numbers behave.

01

Clean

strip, replace.

02

Standardize

upper, lower, title.

03

Reshape

split, join.

04

Report

f-strings.

Frequently Asked Questions

String Methods — FAQs

Do string methods change the original string?

No. Strings are immutable. Every method returns a new string; the original is untouched.

How is split() the opposite of join()?

split() breaks a string into a list. join() takes a list and glues it into one string with a separator.

What does replace() do to every match?

It swaps all occurrences by default. Pass a third argument for a limited number of replacements.

Why do f-strings need the f prefix?

Without the f, { } are literal characters. The f tells Python to evaluate them as expressions.

Lesson Summary

What you learned

upper() / lower()

Change the case of a string.

strip() / replace()

Remove whitespace; swap a substring.

split() / join()

Break a string into a list; glue a list into a string.

find() / count()

Locate a substring; count occurrences.

Chaining

Chain methods left to right on the result of the previous call.

f-strings

Insert variables into text with { } inside an f-prefixed string.