Question

trees = ['coconut', 'sequoia', 'weeping', '23', '24', '25', 200, '26', '27', '28', 300, 'T'] I need...

trees = ['coconut', 'sequoia', 'weeping', '23', '24', '25', 200, '26', '27', '28', 300, 'T']

I need a python code that either prints out only certain elements of a list, or appends certain item of a list to a new list then prints out that new list.

For example:

trees = ['coconut', 'sequoia', 'weeping', 300, 'T'] or

trees2 = []

trees2 = ['coconut', 'sequoia', 'weeping', 300, 'T']

0 0
Add a comment Improve this question Transcribed image text
Answer #1
trees = ['coconut', 'sequoia', 'weeping', '23', '24', '25', 200, '26', '27', '28', 300, 'T']

trees2 = []  # create an empty list
for i in range(len(trees)):  # go through all items in trees
    if i < 3 or i >= 10:  # if a certain condition is true
        trees2.append(trees[i])  # then add item to new list
print(trees2)  # print the new list

# we can do exact thing with slicing as well..
trees2 = trees[:3] + trees[10:]
print(trees2)

[coconut, sequoia, weeping, 300, T] [coconut, sequoia, weeping, 300, T] Process finished with exit code o

Add a comment
Know the answer?
Add Answer to:
trees = ['coconut', 'sequoia', 'weeping', '23', '24', '25', 200, '26', '27', '28', 300, 'T'] I need...
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
  • Questions 24, 25, 26, 27 & 28 plz! T and t . A tomato plant homozygous...

    Questions 24, 25, 26, 27 & 28 plz! T and t . A tomato plant homozygous for tall stature and oblong fruit is pollenated by a plant that is homozygous for dwarf stature and normal-shaped fruit. Note that these genes belong to one linkage group. (See Ex. III, Part A. traits list) 24. What are the genotypes of the parents? tall/oblong – Dwarf/normal 25. What alleles will the sperm carry? What alleles will the eggs carry? 26. What are the...

  • really need some help Previous 21 22 23 24 25 26 27 28 Next Question 21...

    really need some help Previous 21 22 23 24 25 26 27 28 Next Question 21 of 28 (4 points) View problem in a pop-up 8.3 Section Exercise 19 A survey of 15 large U.S. cities finds that the average commute time one way is 25.4 minutes. A chamber of commerce executive feels that the commute time in his city is less and wants to publicize this. He randomly selects 29 commuters and finds the average is 24.6 minutes with...

  • Previous 21 22 23 24 25 26 27 28 Next Question 28 of 28 (6 points)...

    Previous 21 22 23 24 25 26 27 28 Next Question 28 of 28 (6 points) View problem in a pop-up 8.6 Section Exercise 2 1,2 The average one-way airfare from Pittsburgh to Washington D.C. is $236. A random sample of 24 one-way fares during a particular month had a mean of $213 with a standard deviation of $43. At a = 0.01, is there sufficient evidence to conclude a difference from the stated mean? Source: www.fedstats.gov Part 1 out...

  • 22 23 24 25 26 27 28 2 BON SIN 32 QUESTIONS Which of the following...

    22 23 24 25 26 27 28 2 BON SIN 32 QUESTIONS Which of the following compounds would you expect to react with a nucleophile at the highest rate? Save and Sub TOSHIBA

  • - 22 23 24 25 26 27 28 29 30 32 Rank the indicated bond angles...

    - 22 23 24 25 26 27 28 29 30 32 Rank the indicated bond angles in the molecule shown below in order of increasing bond angle. (Lone pairs are NOT explicitly shown.) Η Ο Υ Η Η Β Ο Ο οοοο α<<γ«β γ<α- β - και δ = α<<y Ο Ο δ = α<β =y Ο γδ <α<β

  • 23. TF 24. T F 25. T F Prototypes are one of the best forms of...

    23. TF 24. T F 25. T F Prototypes are one of the best forms of quality software. In unit testing, it is better to run unit tests manually since units are small. In pair programming, a programmer sits with two workstations to develop the software. Refactoring is used to improve code without changing the code's functionality. Managers' second-guessing of team members will increase trust in the team. Writing pseudo code requires selecting a specific programming language. 26. T F...

  • 23 24 25 26 27 28 29 30 - 31 32 33 34 In the Periodic...

    23 24 25 26 27 28 29 30 - 31 32 33 34 In the Periodic Table below, shade all the elements for which the neutral atom has a valence electron configuration of n s mp', where n stands for an integer. H Li Be Na Mg K Ca Sc Rb Sr Y Cs Ba La Fr Ra Ac He BC N O F Ne Al Si P S Clar TV Cr Mn Fe Co Ni Cu Zn Ga Ge...

  • (ignore #12 at the bottom) This is part of a quiz and i need to "check...

    (ignore #12 at the bottom) This is part of a quiz and i need to "check all that apply" but I keep missing a few. Please list all the elements that apply below and some reasoning behind it-thank you!! Question 11 O out of 1 points Which elements are transition metals? These elements have incompletely filled d subshells or readily give rise to cations that have incompletely filled d subshells. Selected Answers: 21. Scandium 22. Titanium 23. Vanadium 24. Chromium...

  • 26. 27. 28 it doesnt let me eddit the questins. I need 27 and 28 if...

    26. 27. 28 it doesnt let me eddit the questins. I need 27 and 28 if you can, but 27 is my priority 26. Are any of the following losses deductible an individual's income tax return? If so, ish loss deductible "for" or "from" AGI? Explain cach loss. Amount 3.000 Loss Loss on sale of stock in an individual's wholly-owned business corporation Hobby loss in excess of hobby gross income Gambling losses in excess of gambling winnings Loss on sale...

  • 23-27 23. At May 1,2017, Heineken Company had beginning inventory consisting of 300 units with a...

    23-27 23. At May 1,2017, Heineken Company had beginning inventory consisting of 300 units with a unit cost of $7. During May, the company purchased inventory as follows 600 units at 57 900 units at 5 The company sold 1,500 units during the month for $12 per unit. Heincken uses the averape cost method. Heineken's gross peofit for the month of May is A) 56,750 B) $11,250 C) $18,000 D) $13,500 -24. In a period of rising prices, which of...

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