Why is #Python's join() a STRING method, not a list method? x = 'this is a test'.split() '*'.join(x) ':::'.join(x) Not: x.join('*') Why not? The argument can be any string-returning iterable: '*'.join('abcde') '*'.join(str(x) for x in range(5)) '*'.join(open('filename.txt'))
Understanding Python's join() Method for Strings
More Relevant Posts
-
🚀 Dictionaries: Key-Value Pairs (Python) Dictionaries are unordered collections of key-value pairs. They are defined using curly braces `{}`. Keys must be unique and immutable (e.g., strings, numbers, or tuples), while values can be of any data type. Dictionaries are highly efficient for looking up values based on their keys. They are widely used for representing structured data and implementing mappings. Learn more on our app: https://lnkd.in/gefySfsc #Python #PythonDev #DataScience #WebDev #professional #career #development
To view or add a comment, sign in
-
-
Most Python code runs on one core — even if your machine has 8, 12, or 16. That’s fine… until your script starts taking forever 😪 ✨Multiprocessing✨ can change that! But here’s the catch: it's often misunderstood, misused, or missed entirely. This post isn’t just “how it works.” It’s about when it actually helps, what to avoid, and how it compares to the other options — threading and asyncio. You’ll leave knowing when not to reach for multiprocessing — which is just as important. 📎 Link in comments to get the full breakdown! (with code examples and real use cases) #Python #SoftwareEngineering #CodePerformance #DataEngineering #PythonTips #ScalableCode #BackendDevelopment #HighPerformanceComputing #AsyncProgramming #DeveloperInsights #StrataScratch
To view or add a comment, sign in
-
LeetCode Problem 392: "Is Subsequence": Given two strings s and t, return true if s is a subsequence of t, or false otherwise. A subsequence of a string is a new string that is formed from the original string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (i.e., "ace" is a subsequence of "abcde" while "aec" is not). The below implementation in Python resolves this problem using Two-Pointers strategy. #DSA #LeetCode #Python #TwoPointers #CompetitiveProgramming #InterviewPrep #DataStructures #Algorithms #OptimalSolution
To view or add a comment, sign in
-
-
✨ Python Escape Characters ✨ Exploring how special characters work inside strings using escape sequences in Python. These help us control text formatting and display special symbols properly. 📌 Common Escape Characters: ✔️ \' → Single Quote ✔️ \\ → Backslash ✔️ \n → New line ✔️ \r → Carriage Return ✔️ \t → Tab ✔️ \b → Backspace ✔️ \f → Form Feed ✔️ \000 → Octal value ✔️ \xhh → Hex value These are useful when working with text files, user inputs, and formatted outputs. 💻✨ Learning step by step, growing every day 🚀 #Python #EscapeCharacters #LearningPython #ProgrammingBasics #CodingJourney #DeveloperLife #Upskilling #DataAnalytics #TechSkills #Consistency
To view or add a comment, sign in
-
-
Python’s 'if' Statement seems simple, but 'if' in Python has quirks—and knowing how it really works separates script kiddies from serious devs. This post covers syntax, indentation drama, chained conditions, and more. Get your logic straight and write code that flows. #Python #CodeSmart #ConditionalLogic #LearnToCode #RheinwerkComputingBlog Dive into the details: https://hubs.la/Q03_jXm70
To view or add a comment, sign in
-
-
How much memory does a text column in your #Python #Pandas data frame use? Check: df['x'].memory_usage() But this is likely a huge underestimate! It sums the pointer sizes, not the string sizes. Instead, say: df['x'].memory_usage(deep=True) Or: df.info(memory_usage='deep')
To view or add a comment, sign in
-
-
How Python Manages Memory: Mutable vs Immutable One concept that silently affects performance, bugs, and behavior in Python is mutability. Immutable objects 👉 int, float, str, tuple Their value cannot be changed in place Any “modification” creates a new object in memory Safer, predictable, hashable (used as dict keys) Mutable objects 👉 list, dict, set Can be modified without changing memory reference Faster updates, but risk of unexpected side effects Changes reflect across all references Why this matters in real projects - Unexpected bugs when modifying lists passed to functions - Memory inefficiency when repeatedly modifying strings - Confusing behavior in function arguments & shared data #Python #MemoryManagement #Mutable #Immutable #PythonInternals #SoftwareEngineering
To view or add a comment, sign in
-
🐍 #python tips: (range(len(...))) If you’re looping over indexes just to access values, Python has a better, cleaner option: enumerate(). Why it’s better: ✔️ More readable ✔️ Fewer off-by-one bugs ✔️ Idiomatic Python ✔️ Small changes like this compound into more maintainable code What’s interesting is that modern code generators and AI assistants already prefer patterns like enumerate() because they encode intent, not just mechanics. The clearer your code, the better both humans and tools can reason about it. Clean code isn’t about clever tricks! It’s about making the next reader (or code generator) faster and safer. What do you think? #Python #ProgrammingTips #CleanCode #SoftwareEngineering #DeveloperExperience #CodeQuality
To view or add a comment, sign in
-
-
Hello Python folks Quick brain-teaser for you: What does this print — and why? t = ([1, 2],) t[0] += [3] print(t) Did the tuple mutate? Or did Python just trick your mental model? Most people answer quickly. Very few explain it correctly. If you can explain this in terms of identity, mutation vs rebinding, you truly understand Python. Full breakdown here including👇 - Shallow Vs Deep Copy - Default Mutable Argument Trap https://lnkd.in/e_v6nNej #python #pythoninterview #softwaredevelopment
To view or add a comment, sign in
More from this author
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
...and Python's developers were smart enough to make these as methods, and not to have something as dumb as java.util.Arrays. Or whatever the heck PHP does.