• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

Roger Perkin

Network Automation Architect

  • Network Automation
    • Network Automation Courses
    • What is NetDevOps?
    • Workflow Orchestration
    • Ansible Automation Platform
    • Ansible Workshop
    • What is Network Automation?
    • Network Automation Tools
    • ContainerLab
    • Ansible Training
      • What is Ansible?
      • Ansible Tutorial for Beginners
      • Ansible Network Automation
      • Ansible Inventory Example
    • Python Network Automation
      • Nornir
      • Python Network Automation Course
      • Python for Network Engineers
      • Python VENV / Virtual Environment Tutorial
      • Python Tutorial for Beginners
      • pyATS
    • Network Source of Truth
      • NetBox
      • Infrahub
      • NautoBot
    • NetDevops
    • DevOps Tutorial
      • Git Training
      • Terraform Training
      • Linux Training
      • Kubernetes Training
      • Devops Training Course
      • Azure Devops Training
    • Terraform
    • GIT
      • Git Commands
      • What is GitHub?
    • Docker Training
    • Confluence
    • Microsoft Azure
  • Cisco
    • ISE
    • SD WAN Training
    • Password Recovery
    • Software-Upgrade-Guides
    • BGP
    • Data Center
    • WIRELESS
  • CCIE
  • Blog
  • About
    • My Red Special Guitar
  • Contact

Python Strings Tutorial

Home » Python Tutorial for Beginners » Python Data Types

Out of all the Python Data Types strings are probably the most common.

Strings are text enclosed in quotes, either single or double quotation marks.

“This is a string in Python”
‘This is also a string in Python’

If you have a multi-line string you need to surround it in triple quotes.

“”” This is a string
that will span
many lines “””

You can also use three single quotes.

Python String Methods

Python has a set of built-in methods that you can use against strings.

For a full list of string methods check here – https://docs.python.org/3/library/stdtypes.html

An example of a Python string method is split()

Python String Split

You can split a string into a list, the default separator is whitespace.

sentence = "This is a sentence with no separators" 

x = txt.split()

print(x) 

The output of this will be a list separated by the whitespace.

['This', 'is', 'a', 'sentence', 'with', 'no', 'separators']

If you want to split the string at a certain point, you define the separator as below.

sentence = "This is a sentence, with a comma"

x = txt.split(", ")

print(x)

The output from this will be a list generated from the string but split at the comma.

['This is a sentence', 'with a comma']

Python String Format

Python f-string

Python String Concatenation

Next Lesson – Python Dictionaries

See my full Python Tutorial for Beginners

Sidebar

Quick Links

Python Data Types
- Strings
- Dictionaries

Let’s get started

Take a look at my premium courses on Ansible, Nornir & Git or buy them all with the Network Automation Bundle!

Network Automation Courses

Navigation

Python VENV Tutorial
Python for Network Engineers

Network Automation
Network Automation Courses
Network Discovery Tools
Network Automation Conferences
Ansible Training
What is Ansible?
Devops Tutorial
Network Source of Truth
DevOps Glossary
Network Monitoring Software

Contact

Contact

Get in touch with me here

[email protected]

  • Twitter
  • LinkedIn
  • YouTube
Buy me a coffeeBuy me a coffee

Copyright © 2026 · Roger Perkin · All Rights Reserved · Privacy Policy – Terms