Changes

Jump to: navigation, search

OPS435 Python Lab 4

62 bytes removed, 09:56, 21 June 2017
PART 1 - Strings and Substrings
</source>You can use a technique that uses index numbers of a string to '''cut-out''' or '''"parse"''' smaller portions of text within a string. This term is referred to as a '''substring'''. We can use this to create a new string or display only a small portion of it<br><br>
:#To demonstrate, issue the following:<source>
course_name[0:4] # This will return Return the first four characters NOT including (values of index 4 -> indexes numbers 0,1,2,and 3 -> but not index 4)
first_word = course_name[0:4] # Save this substring for later use
course_code[0:3] # This will return Return the first three characters NOT including (values of index 3 -> indexes numbers 0,1,and 2 -> but not index 3)
</source>
:# The index allows some extra functions using the colon and negative numbers<source>
13,420
edits

Navigation menu