Changes

Jump to: navigation, search

OPS435 Python Lab 4

54 bytes added, 09:59, 21 June 2017
PART 1 - Strings and Substrings
course_code[0:3] # Return the first three characters (values of index numbers 0,1,and 2)
</source>
:# The index allows some a few '''extra functions ''' using the colon and negative numberssame parsing technique:<source>
course_name = 'Open System Automation'
course_name[12:] # Return the substring '12' index until end of string
course_name[5:] # Return the substring '5' index until end of string
course_name[-1] # Return the last character
</source>:#With '''negative indexes the index works from the right side of the string ''', '''-1''' being index would represent the '''last ''' character, '''-2''' index would represent the ''' second last ''' character, and so onetc.<br><br>:#To demonstrate, issue the following:<source>
course_name = 'Open System Automation'
course_name[-1]
13,420
edits

Navigation menu