Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk2 min

How to Remove the First Character from a Python String

Use s[1:] to create a string without its first element. Learn how slicing handles empty strings, why strings cannot be changed in place, and when Unicode grapheme handling matters.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use s[1:] to get a new string containing everything after the first element of s. For example, "Python"[1:] evaluates to "ython". The original string is unchanged.

Use a slice to drop the first element

Python sequence indexes start at zero: index 0 is the first element, and index 1 is the second. A slice beginning at index 1 skips the first element and runs to the end; leaving off the stop index means the slice continues through the sequence.

s = "Python"
result = s[1:]  # "ython"

The slice returns a string value. Python strings are immutable, so it does not alter the string that s refers to. Assign the result to a name if you need to keep using it.

What happens with empty and one-character strings?

The same slice works for both cases. When the start index is beyond the available sequence, slicing returns an empty string rather than raising an indexing error.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
"Python"[1:]  # "ython"
"A"[1:]       # ""
""[1:]        # ""

Why item assignment and deletion do not work

Indexing can retrieve an element, but it cannot remove or replace an element in a string. Expressions such as s[0] = "" and del s[0] attempt to mutate an immutable string and fail. Create the desired value with s[1:] instead.

Choose the operation that matches your intent

  • Drop the first element regardless of what it is: use s[1:].
  • Remove a particular prefix only when present: use s.removeprefix(prefix). It removes the specified prefix conditionally, rather than discarding one element unconditionally.
  • Remove leading whitespace: use s.lstrip(). It strips whitespace by default, not one arbitrary first element. If passed a string of characters, lstrip(chars) strips leading characters drawn from that set; it does not remove that exact string as a single prefix.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What “character” means for Unicode strings

Python strings are sequences of Unicode code points, and indexing a non-empty string produces a one-element string. Therefore s[1:] removes one code point from the start. A visible symbol may consist of multiple code points—for example, a letter followed by a combining mark or an emoji sequence—so a slice can split a symbol that appears as one character on screen. If you need to remove one whole user-perceived grapheme, use grapheme-aware segmentation rather than ordinary string slicing.

See the Python documentation on text and slicing and the built-in str type.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.