Input N Integers and Print Them
Input n and take n integers; print them.
BeginnerPhase 4 - Level 1: Basic ArraysExample 1 of 10
input-n-integers-and-print-them.py
1# Take n as input2n = int(input("Enter number of elements: "))34# Input array5arr = []6print("Enter elements:")7for i in range(n):8 element = int(input())9 arr.append(element)1011# Print array12print("Array elements:")13for element in arr:14 print(element, end=" ")15print()
Output
Enter number of elements: 5 Enter elements: 10 20 30 40 50 Array elements: 10 20 30 40 50
What's going on
Use loop to input elements and append to list.
Key Concepts:
Create empty list
Loop n times to input elements
Append each element to list
Print all elements
🔗Related Content
- 📖
Phase 4 - Learn Concepts
Review Phase 4 concepts and explanations
- 📝
Phase 4 - Quiz
Test your Phase 4 understanding with quiz questions
- 💻
Phase 4 - All Practice Problems
Explore all practice problems for Phase 4
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum