← Back to Blog

Common String Mistakes

The problem...

You know how strings work. But knowing how something works doesn't mean you won't break it.

These are the mistakes almost every beginner makes. At least once.

Mistake 1 — Forgetting to close a quote

# Wrong
name = "Bull

# Right
name = "Bull"

Python reads until it finds the closing quote. If it never finds it, everything breaks.

Mistake 2 — Mixing quote types

# Wrong
name = "Bull'

# Right
name = "Bull"
# or
name = 'Bull'

Open and close with the same type of quote. Always.

Mistake 3 — Indexing starts at 0, not 1

name = "Bull"

# Wrong — expecting B but getting u
print(name[1])   # u

# Right
print(name[0])   # B

This one trips up almost everyone. Twice.

Mistake 4 — Index out of range

name = "Bull"

# Wrong — "Bull" has indexes 0, 1, 2, 3
print(name[4])   # IndexError

If you go beyond the last index, Python throws an error. Check the length first if you're not sure.

Mistake 5 — Thinking methods change the original string

name = "bull"
name.upper()

# Wrong — expecting BULL
print(name)   # bull — unchanged

# Right
name = name.upper()
print(name)   # BULL

Methods return a new string. They don't touch the original unless you reassign.

Mistake 6 — Adding a string and a number

age = 25

# Wrong
print("I am " + age)        # TypeError

# Right
print("I am " + str(age))   # I am 25
# or
print(f"I am {age}")        # I am 25

You can't combine a string and a number directly. Convert first, or use an f-string.

Mistake 7 — Case sensitivity in comparisons

name = "Bull"

# Wrong — expecting True
print("bull" in name)    # False

# Right
print("Bull" in name)    # True
# or normalize first
print("bull" in name.lower())   # True

Python sees "Bull" and "bull" as completely different things.

What's really happening

Most of these mistakes are not about not understanding strings.

They're about assumptions. You assume indexing starts at 1. You assume methods modify in place. You assume Python figures out the type.

It doesn't. Be explicit. Always.

The mindset shift

Stop thinking: "This should work."

Start thinking: "Let me check exactly what Python expects."

What you should understand now

  • Quotes must match — open and close with the same type
  • Indexes start at 0
  • Methods return a new string — reassign if you want to keep the change
  • You can't add a string and a number — convert first
  • Strings are case sensitive
[ login to bookmark ] // copied! 49 views · 2 min
// resources
Other string_mistakes.py
← prev Your First Mini Project — Put It All Together next → Strings — The Full Picture
// 0 comments
// No comments yet. Be the first.
// leave a comment

// Your comment will appear after approval.