<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Strings</id>
	<title>Strings - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Strings"/>
	<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Strings&amp;action=history"/>
	<updated>2026-05-14T02:25:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://training-course-material.com/index.php?title=Strings&amp;diff=9201&amp;oldid=prev</id>
		<title>Kristian Rother at 20:03, 5 February 2013</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Strings&amp;diff=9201&amp;oldid=prev"/>
		<updated>2013-02-05T20:03:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Cat|Python Commands}}&lt;br /&gt;
{{Python Links}}&lt;br /&gt;
&lt;br /&gt;
== Accessing individual characters ==&lt;br /&gt;
Using square brackets, any character of a string can be accessed. The first character has the index 0.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s = &amp;#039;Manipulating Strings&amp;#039;&lt;br /&gt;
print s[0] # first character&lt;br /&gt;
print s[3]&lt;br /&gt;
print s[-1] # last character&lt;br /&gt;
print s[-2] # second last&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating substrings ==&lt;br /&gt;
Substrings can be formed by applying square brackets with two numbers inside separated by a colon. The second number is not included in the substring itself.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s = &amp;#039;Manipulating Strings&amp;#039;&lt;br /&gt;
print s[1:6] # &amp;#039;anipu&amp;#039;&lt;br /&gt;
Print s[9:13] # &amp;#039;ing &amp;#039;&lt;br /&gt;
print s[0:2] # &amp;#039;Ma&amp;#039;&lt;br /&gt;
print s[:3]&lt;br /&gt;
# &amp;#039;Man&amp;#039;&lt;br /&gt;
print s[-4:] # &amp;#039;ings&amp;#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Length of strings ==&lt;br /&gt;
Is returned as an integer by the len() function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
print len(&amp;#039;Manipulating Strings&amp;#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== String functions ==&lt;br /&gt;
There is a number of functions that can be used on every string variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s = &amp;#039;Manipulating Strings &amp;#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Changing case: =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s.upper()&lt;br /&gt;
&lt;br /&gt;
s.lower()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Removing whitespace at both ends: =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s.strip()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Cutting a string into columns: =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s.split(&amp;#039; &amp;#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Searching for substrings: =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
print s.find(&amp;#039;ing&amp;#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Replacing substrings: =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
print s.replace(&amp;#039;Strings&amp;#039;,&amp;#039;text&amp;#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Removing whitespace at both ends: =====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
s.startswith(&amp;#039;Man&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
s.endswith(&amp;#039;ings&amp;#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kristian Rother</name></author>
	</entry>
</feed>