Question

The following lines of code are supposed to add elements to a list, one at a...

The following lines of code are supposed to add elements to a list, one at a time. However, they do not seem to work correctly. Fix each line so that all elements are able to be appended one at a time.

Given code:

things = []
things = things.append("Dogs")
things = things.append("Cups")
things = things.append("Cards")
things = things.append("Petals")
things = print(things)

do in python

0 0
Add a comment Improve this question Transcribed image text
Answer #1
things = []
things.append("Dogs")
things.append("Cups")
things.append("Cards")
things.append("Petals")
print(things)

media%2Fbbe%2Fbbed2c3e-0854-4ab7-80c1-9a

Add a comment
Know the answer?
Add Answer to:
The following lines of code are supposed to add elements to a list, one at a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE ADD COMMENTS EXPLAINING EACH LINE OF CODE THANK YOU QUES TION 7 10 points Save...

    PLEASE ADD COMMENTS EXPLAINING EACH LINE OF CODE THANK YOU QUES TION 7 10 points Save Answer The following program tries to print all the elements of the numbers list. However, it does not work! Please describe the issue and fix the error. numbers-3,5,7,9 for i in (len (numbers)): print (numbers [i]) TTT Arial ▼T. :- . -. , 3112pt) Path:

  • Java code: Use at least one array defined in your code and one array or array...

    Java code: Use at least one array defined in your code and one array or array list defined by user input.    Examples of arrays you can define in code are: A deck of cards, the days of the week, the months of a year. User input can be things like grades, shopping list items, wish lists, deposits an withdrawals, etc. Be able to add, remove, print, sort as necessary to complete the program's goal. Thanks

  • JAVA Create an ArrayList called list of type Character 2. Add the following five elements |...

    JAVA Create an ArrayList called list of type Character 2. Add the following five elements | < \ / > (4 points) 3. Print the elements of the list, with a label (3 points) 4. Delete the last element of the list (4 points) 5. Use the method size to determine how many elements there are in the list (no hard-coded numbers). Print the number of elements. (3 points) 6. Add a plus sign ( + ) to the list...

  • Provide Python code that does the following: Create the following list in your program: lst1 =...

    Provide Python code that does the following: Create the following list in your program: lst1 = ["apple", "banana", "pear", "grapefruit", "pineapple", "grape", "guava", "plum", "peach"] Write code that then does the following: Print the last item in the list. Print the first item in the list. Print all but the last three items in the list. Print the first, third, fifth etc. items of the list. Print the second, fourth, sixth etc. items of the list. Parts A- E should...

  • Create a new program in Mu and save it as ps4.5.2.py and take the code below...

    Create a new program in Mu and save it as ps4.5.2.py and take the code below and fix it as indicated in the comments: # Do not change the line of code below. It's at the top of # the file to ensure that it runs before any of your code. # You will be able to access french_dict from inside your # function. french_dict = {"me": "moi", "hello": "bonjour", "goodbye": "au revoir", "cat": "chat", "dog": "chien", "and": "et"} #...

  • Create a new program in Mu and save it as ps3.3.1.py and take the code below...

    Create a new program in Mu and save it as ps3.3.1.py and take the code below and fix it as indicated in the comments: mystery_int = 50 # You may modify the lines of code above, but don't move them! # When you Submit your code, it should work with # different values for the variables. # Write a for loop that prints every third number from 1 to # mystery_int inclusive (meaning that if mystery_int is 7, it #...

  • 3. Write Python statements that will do the following: a) Input a string from the user....

    3. Write Python statements that will do the following: a) Input a string from the user. *** Print meaningful messages along with your output.* b) Print the length of the String. Example input: The sky is blue. Correct output: The length of the string is 16 Incorrect output: 16 c) Print the first character of the string. d) Print the last character of the string. 4. Save the program. Double-check the left edge for syntax errors or warning symbols before...

  • Deletion of List Elements The del statement removes an element or slice from a list by position....

    Deletion of List Elements The del statement removes an element or slice from a list by position. The list method list.remove(item) removes an element from a list by it value (deletes the first occurance of item) For example: a = ['one', 'two', 'three'] del a[1] for s in a: print(s) b = ['a', 'b', 'c', 'd', 'e', 'f', 'a', 'b'] del b[1:5] print(b) b.remove('a') print(b) # Output: ''' one three ['a', 'f', 'a', 'b'] ['f', 'a', 'b'] ''' Your textbook...

  • Python   #complete the following lines of code wherever indicated. 5 question 20 points a piece #you...

    Python   #complete the following lines of code wherever indicated. 5 question 20 points a piece #you may use your book and internet but no form of messaging or communication #QUESTION 1 #Read in the file exam_file.txt #Print to the console every other line #QUESTION 2 #Read in exam_file.txt #split file into words #write to a file called question2.out that contains 1 word per line (words can occur more than once) #QUESTION 3 # Print out all the Middle Initials in...

  • Python #complete the following lines of code wherever indicated. 5 question 20 points a piece #you...

    Python #complete the following lines of code wherever indicated. 5 question 20 points a piece #you may use your book and internet but no form of messaging or communication #QUESTION 1 #Read in the file exam_file.txt #Print to the console every other line #QUESTION 2 #Read in exam_file.txt #split file into words #write to a file called question2.out that contains 1 word per line (words can occur more than once) #QUESTION 3 # Print out all the Middle Initials in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT