Python: Generate and prints a list of numbers from 1 to 10
Python Basic - 1: Exercise-115 with Solution
Write a Python program to generate and print a list of numbers from 1 to 10.
Expected output:
[1, 2, 3, 4, 5, 6, 7, 8, 9]
['1', '2', '3', '4', '5', '6', '7', '8', '9']
Sample Solution:
Python Code:
nums = range(1,10)
print(list(nums))
print(list(map(str, nums)))
Sample Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9] ['1', '2', '3', '4', '5', '6', '7', '8', '9']
Flowchart:

Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to print letters from the English alphabet from a-z and A-Z.
Next: Write a Python program to identify nonprime numbers between 1 to 100 (integers). Print the nonprime numbers.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join