friend1 = "Sarah" friend2 = "James" mystring = "My friends are {} and ".format(friend1,…
Jump to turn (8)
- 1friend1 = "Sarah" friend2 = "James" mystring = "My friends are {} and ".format(f
- 2This program has a logic error! It doesn't create an error message, but it's not
- 3mylist = ["red","blue",54,"green", "yellow"] del mylist[2:4] print(mylist) This
- 4✓- Did you try changing the range of indexes after the del command?
- 5This program has a logic error! It doesn't create an error message, but it's not
- 6no
- 7Fix the program by changing the range of indexes in del to remove only 54 from t
- 8rainbow = ["red", "orange", "yellow", "green", "black"] index = rainbow.index(4)
- User
friend1 = "Sarah" friend2 = "James"
my_string = "My friends are {} and ".format(friend1, friend2) print(my_string)
friend1 = "Sarah" friend2 = "James"
my_string = "My friends are {} and ".format(friend1, friend2) print(my_string)
- Assistant
My friends are Sarah and James.
- User
This program has a logic error! It doesn't create an error message, but it's not doing what it should.
RULE: String formatting uses {curly brackets} to indicate where variables should go in a string.
Click Run and read the output in the console. Fix the program by adding another set of {} so that both friends' names are printed. Click Run to see if you fixed the program. When it is fixed, click Submit and Next.