Answer to Question #254367 in Python for Hazel

Question #254367

1. String Replacement

by CodeChum Admin

Lists are fun to make, but it's even better to add or remove things from it when it's not usable anymore, right? Let's do just that in this problem now!


Instructions

  1. Create two variables that will accept string values.
  2. A list containing three string values is already given to you in the code editor on the side. First, insert the first inputted string to the end of the list.
  3. Then, insert the second inputted string into the beginning of the list.
  4. There are now 5 elements on the given list. Now, remove the 3rd element of the list. Apply the concept of index positions in order to access the 3rd string element and successfully remove it from the list.
  5. Print out the remaining contents on the list, each separated by a new line, using loops.

Input

Two lines containing a string.

fun
Python

Output

A line containing a string.

Python·is·really·fun
1
Expert's answer
2021-10-21T00:50:42-0400
s1 = input()
s2 = input()

given_list = ["foo", "fun", "bar"]

given_list.append(s1)
given_list.insert(0, s2)
given_list.remove(given_list[2])

for i in given_list:
    print(i)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS