Jump to content

Boston Python Workshop 3/Friday/Tutorial: Difference between revisions

imported>Jesstess
imported>Jesstess
Line 226:
type(1)
type("1")
</pre>
 
There's another useful function that works on strings called <code>len</code>. <code>len</code> returns the length of a string:
 
<pre>
string = "Hello"
len(string)
print len("triskaidekaphobia")
length = len("")
print length
</pre>
 
Line 291 ⟶ 281:
 
Like the <code>type</code> function from before, the <code>str</code> function takes 1 argument, in the example the integer 1. <code>str</code> takes in input and produces a string version of that input as output.
 
====String length====
 
There's another useful function that works on strings called <code>len</code>. <code>len</code> returns the length of a string as an integer:
 
<pre>
string = "Hello"
len(string)
length =print len("")
print "The length of triskaidekaphobia is", len("triskaidekaphobia")
</pre>
 
===Quotes===
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.