Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Small and medium teams
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Pharaoh00
python-examples
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
python-examples
/
basic_examples
/
python_strings.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
44 lines (32 loc) · 1.31 KB
master
Breadcrumbs
python-examples
/
basic_examples
/
python_strings.py
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
44 lines (32 loc) · 1.31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
#Note: Python strings are immutable
#Strings can be enclosed in single quotes
print 'Hello World in single quotes'
#Strings can also be enclosed in double quotes
print "Hello World in double quotes"
#Strings can also be enclosed in triple quotes
print """ This is a multiline string
Such strings are also possible in Groovy.
These strings can contain ' as well as " quotes """
#Strings can be continued on the next line
print "This string is continued on the\
next line (in the source) but a newline is not added"
#Raw strings
print r"The newline character is represented with \n"
#The following is a unicode string, but here it is a literal.
#How do we specify that a string read from a file should be held
#as a unicode string. Also the +uXXXX notation does not work in
#Python
print u"This is a unicode string u0600"
#See how the strings are concatenated
print 'hello ' 'world'
#Notice how the print statement accepts , separated values
print '2 + 3 = ', (2+3)
#Getting the length of a string
greeting = "Hello my dear friend how are you?"
print "the length of string '" ,greeting, "' is ", len(greeting)
#Let's check if the string contains the word 'Hello'
if('Hello' in greeting):
print 'This greeting seems to be in English'
if(greeting.find('Hello') != -1):
print 'This greeting seems to be in English'
You can’t perform that action at this time.