Question: python code STRINGS AND LISTS In this lab, you will work with strings and lists. A. In the file lab6.py, write code that will do
STRINGS AND LISTS In this lab, you will work with strings and lists. A. In the file lab6.py, write code that will do the following: 1. Assign to variable str 1 the value "Today is Tuesday". The quaotes are not part of the value. 2. Using slicing, extract the substring "Tuesday" from strl and assign it to the variable str2. 3. Print "The day is Tuesday". "Tuesday" must be printed from str2. 4. Using slicing, extract the last character of str1, and print "The last character of strl is x", where x is the actual last character. 5. Using slicing extract the first character of str1, and print "The first character of strl is x", where x is the actual first character. 6. Using slicing, extract the the substring "is" in strl, and print "The substring is is", where the last "is" is a substring B. Lists: 1. Continuing in the same file lab6.py, you will define the list Days and contains the days of the week: Days - [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday] 2. Print the list Days 3. From the list days extract the sublist [Saturday, Sunday) and assign it to the list Weekend. 4. Print the list Weekend. 5. From the Days list, create a single string with the days of the week separated by a space and assign it to str3. (Hint: use" ".join(str)) 6. Print str3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
