Changes

Jump to: navigation, search

OPS435 Python Lab 4

63 bytes added, 09:16, 21 June 2017
PART 1 - Strings and Substrings
course_name.capitalize() # Returns a string with upper-case first letter only, lowercase for remaining text
</source>
:#These values can be saved inside new strings and then reused for any new tasks:<source>
lower_name = course_name.lower() # Save returned string lower-case string inside new string variable
print(lower_name)
:#If a string contains many values separated by a single character, such as a space, the string can be split on those values and create a list of values<source>
lower_name.split(' ') # Provide the split() function with a character to split on
</source>:#The above example will return a list of strings, which we can access just like all of lists. :#Let's practice more string manipulation by issuing the following:<source>
list_of_strings = lower_name.split(' ') # Split string on spaces and store the list in a variable
list_of_strings # Display list
13,420
edits

Navigation menu