Pradumya Gupta’s Post

🚀 Day 48 of #100DaysOfCode — Getting the Last Element of an Array Hey everyone! 👋 Today’s challenge was simple but fundamental: returning the last element of an array without modifying it. 👨💻 What I practiced today: ✅ Accessing array elements by index ✅ Using negative indexing in Python ✅ Writing clean, one-line return statements ✅ Handling edge cases implicitly 📌 Today's Task: ✔ Create a function get_last(arr) ✔ Return the last element of the given array ✔ Keep the original array unchanged 🧠 Example: Input: [1, 2, 3] Output: 3 Input: ["a", "b", "c"] Output: "c" 💡 Key Takeaway: Even simple operations like accessing the last element are essential building blocks in programming. Python’s negative indexing makes this elegant and readable. #100DaysOfCode #Python #Arrays #Indexing #BeginnerFriendly #CodingJourney #Day48

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories