Python: Display the first and last colors from a given list
Python Basic: Exercise-8 with Solution
Write a Python program to display the first and last colors from the following list.
color_list = ["Red","Green","White" ,"Black"]
color_list = ["Red","Green","White" ,"Black"] print( "%s %s"%(color_list,color_list[-1]))
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to accept a filename from the user and print the extension of that.
Next: Write a Python program to display the examination schedule. (extract the date from exam_st_date).
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
>>> m = [x ** 2 for x in range(5)] >>> m [0, 1, 4, 9, 16]
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework