Convert Array to String
Convert array of numbers to string.
IntermediatePhase 6 - Category 2: Array & String CombinationsExample 1 of 10
convert-array-to-string.py
1# Take array2n = int(input("Enter array size: "))3arr = []4for i in range(n):5 arr.append(int(input(f"Element {i+1}: ")))67# Convert to string8result = "".join(str(x) for x in arr)9print(f"String: {result}")
Output
Enter array size: 5 Element 1: 1 Element 2: 2 Element 2: 3 Element 4: 4 Element 5: 5 String: 12345
What's going on
Convert each element to string and join.
Key Concepts:
Convert each number to string
Join without separator
Creates concatenated string
🔗Related Content
- 📖
Phase 6 - Learn Concepts
Review Phase 6 concepts and explanations
- 📝
Phase 6 - Quiz
Test your Phase 6 understanding with quiz questions
- 💻
Phase 6 - All Practice Problems
Explore all practice problems for Phase 6
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum