⚡ Python Tip: list.append(x) vs list.extend(x) 👉 append(): Adds one element [1,2].append([3,4]) → [1,2,[3,4]] 👉 extend(): Adds elements individually [1,2].extend([3,4]) → [1,2,3,4] 📌 Small difference. Big impact. #Python #CodingTips #LearnPython
Python list append vs extend
More Relevant Posts
-
Tiny Python upgrade for cleaner analytics code: Use Counter instead of manual dict increments. You get frequency maps in one pass and top-N insights with most_common(). Less boilerplate, fewer mistakes, faster review. Mini pattern: - counts = Counter(values) - top = counts.most_common(3) - act on thresholds #Python #CodingTips #Backend #DevTips #SoftwareEngineering
To view or add a comment, sign in
-
-
There is an important python concept hidden here , can you guess what ? class Hai: def show(self,a,b): print('Hai - show()') print(a,b) class Hello(Hai): def show(self,a): print('Hello - show()') print(a) hello = Hello() hello.show(10) hello.show(10,20) #python
To view or add a comment, sign in
-
Fun python 1/100 Ever wondered why these two give different outputs ? Its called Singleton in python …………….. ids = {id(True) for i in range(500)} print(ids) ids = {id(int("100")) for i in range(500)} print(ids) ……………… What you think would be the answer to each loop?
To view or add a comment, sign in
-
Fun python 3/100 X= 10, Y=10 print(type(X)) print(type(Y)) Why the output is not same ? Will it give error for X ?
To view or add a comment, sign in
-
Want to parse a #Python string into a datetime? Use strptime, passing (a) the string and (b) the date format spec: datetime.datetime.strptime('2026-04-01', '%Y-%m-%d') datetime.datetime.strptime('26-April-01', '%y-%B-%d') Both return datetime.datetime(2026, 4, 1, 0, 0)
To view or add a comment, sign in
-
-
Here’s a tiny Python change that pays off fast. Python tip: use `@dataclass(slots=True)` for high-volume models. It removes per-instance `__dict__`, which usually means lower memory usage and slightly faster attribute access. Great for DTOs, parser outputs, event payloads, and cache objects where shape is fixed. Mini rule: if the object schema is stable, add `slots=True` by default. #Python #Performance #CodeQuality #SoftwareEngineering
To view or add a comment, sign in
-
-
✅ Python: 04 🎯 Nested loops Let's share an interesting concept of python. we've this concept called nested loop, here we can use one loop inside of an another loop. We can get some interesting results. Let's take a look- for x in range(2): # outer loop for y in range(3): # inner loop print(f"({x} , {y})") # for co-ordinates 📌Code explanation: The outer loop will be executed 2 times & the inner loop will be executed 3 times, To begin with, the python interpreter will execute the outer loop first then it'll go to the inner loop and execute codes as follows, then it'll print as commanded and then jumps into the outer loop again, this will continue as per the range mentioned in the code. That's how nested loop works. #PythonProgramming #PythonDeveloper #Coding #python #nestedloopinpython #DataScience #pythondeveloper
To view or add a comment, sign in
-
-
🧠 Python Logic Check — Quick Challenge Consider the following snippet: x = 10 x += x == 10 print(x) At first glance, it looks straightforward — but it tests your understanding of how Python handles boolean expressions. 💡 Question: What will be the output? A) 10 B) 11 C) True D) Error 📌 Small details like this often separate beginners from experienced developers. 💬 Drop your answer in the comments — and explain your reasoning if you can. #Python #SoftwareEngineering #CodingChallenge #DeveloperMindset #Learning
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development