Python for Data Analytics • Lesson 5

Strings & String Operations

Learn how Python stores and works with text using strings. Practice creating strings, joining text, repeating strings, finding characters and measuring string length.

Your progress0%

0 of 8 concepts completed

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

Concept 1WHY STRINGS

What Is a String?

A string is a sequence of characters used to represent text. Names, cities, product names and email addresses are all stored as strings.

Learn by Seeing

Text values in quotes

"Hello"
"Vista Academy"
"Python"
"Dehradun"

Anything inside quotes is text, so Python treats it as a string.

Click any value — see its type:

type

str

Quotes make this text.

Interactive Activity

Which of these is a Python string?

Hint: Strings are wrapped in quotes.

Python Analyst Mindset

Text is half the data you'll ever touch

Names, cities, categories, status codes — almost every analytical dataset is half text. Being fluent with strings is what lets you clean, join and shape them without ever leaving Python.

01

Store

Put text in variables.

02

Join

Concatenate with +.

03

Measure

len() and indexing.

04

Convert

str() when mixing types.

Frequently Asked Questions

Strings — FAQs

Are single and double quotes the same?

Yes. Both produce a str. Pick one style and stay consistent.

Does + add spaces between strings?

No. You must include the space yourself, e.g. " " between the parts.

Does len() count spaces?

Yes. Every character, including spaces and punctuation, counts toward the length.

What if I index past the end?

Python raises an IndexError. Valid indexes go from 0 to len-1 (or -1 to -len).

Lesson Summary

What you learned

Strings

Text values wrapped in single or double quotes.

Concatenation with +

Joins two strings; spaces must be added explicitly.

Repetition with *

Repeats the string N times.

len() and indexing

len() counts characters; [i] reads the character at index i (starting at 0).

Negative indexes

-1 is the last character; -2 the second-to-last, etc.

str() conversion

Convert a number to a string before concatenating.