Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task) header
Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task) profile picture

๐Ÿ“– Author, Python Tasks Adventures ๐Ÿ https://www.nitter.gq/t.co/q5LNWHeHZ2 ๐ŸŽฎ Programmer, PyAdventure โ€” free Python learning game https://www.nitter.gq/t.co/EXuNMYiqat

Joined September 2021
Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)Photo by Khalid | Python Tasks Adventurer ๐Ÿ (@Python__Task)
๐Ÿ—บ๏ธ My Python book is now available! ๐Ÿ“˜ Python Tasks Adventures 240 total components โ€” tasks, bonus tasks, tips, and exercises covering a wide range of Python concepts. From spy encryption to restaurant queues to Olympic systems. You don't just learn Python. You practice it. โœ… 700+ pages โœ… Beginner to Advanced โœ… Every solution fully explained ๐Ÿ”ฅ Launch price: $34.99 for 2 weeks only โ†’ then $44.99 ๐Ÿ‘‡ amazon.com/dp/B0H7NKVFX6 โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ๐Ÿ“– BEFORE YOU DECIDE โ€” SEE IT FOR YOURSELF ๐Ÿ‘‰ Read a sample task here โ†’ drive.google.com/file/d/1jjXโ€ฆ ๐Ÿ‘‰ Read more samples free on Amazon โ†’ amazon.com/dp/B0H7NKVFX6 One page. Real story. Real code. Real explanation. That's the standard of all tasks. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” #Python #LearnPython #PythonTips #100DaysOfCode #CodeNewbie
1
1
2
680
๐Ÿ Python tip: find() can trick your if statement! post = '#python is fun' if post.find('#'): print('Has a hashtag!') # never prints if '#' in post: print('Has a hashtag!') # prints โœ… (just need yes/no) pos = post.find('#') if pos != -1: print('Hashtag at', pos) # Hashtag at 0 โœ… (need the position) Why does the first check fail? find() returns the position, not True or False: '#' is at position 0, and 0 counts as False A missing match returns -1, and -1 counts as True The right way: โœ… Just need yes/no? Use in. โœ… Need the position? Use find() and compare with -1. #Python #LearnPython #PythonTips #100DaysOfCode #CodeNewbie #AI #MachineLearning
12
Khalid | Python Tasks Adventurer ๐Ÿ retweeted
๐Ÿ A year of work turning Python into an adventure. PyAdventure โ€” a free learning game built entirely with Pygame. ๐ŸŒ Travel through 10 unique worlds, from Ancient Forests and Desert Ruins to Frozen Lakes, Mystic Archives, and Sky Castles. But every world is more than a new landscape. Each one teaches a real Python concept: โš”๏ธ Variables and data types โš”๏ธ Conditions and loops โš”๏ธ Lists and dictionaries โš”๏ธ Functions and error handling โš”๏ธ Object-oriented programming โ€ฆand more. Answer questions. Overcome obstacles. Unlock the gate. Enter the next world. And waiting at the end is the Dragon of Truth ๐Ÿ‰ A real final battle where every Python skill you have learned is put to the test. Can you master Python and defeat the Dragon? ๐ŸŽฎ Free. Windows download. khalidmfy.itch.io/pyadventurโ€ฆ #Python #100DaysOfCode #CodeNewbie
2
1
1
5
4,707
๐Ÿ Python tip: string methods donโ€™t change your string! title = 'python tips' title.upper() print(title) # python tips ๐Ÿ˜ฎ (nothing changed!) title = title.upper() print(title) # PYTHON TIPS โœ… Why? Strings in Python are immutable: they can never be changed after theyโ€™re created. A method like upper() doesnโ€™t edit the string. It builds a new one and returns it. If you donโ€™t save that new string, itโ€™s thrown away. ๐Ÿ—‘๏ธ The right way: โœ… Save the result: title = title.upper() โœ… The same rule applies to replace(), strip(), lower() and every other string method. #Python #LearnPython #PythonTips #100DaysOfCode #CodeNewbie #AI #MachineLearning
17
Which is more Pythonic? ๐Ÿ๐ŸŽฎ # A is_move_key = lambda key: key.upper() in "WASD" # B is_move_key = lambda key: key in "wasdWASD" A makes the key uppercase before checking. B checks both cases directly. Both accept "w". In a million checks of "w", B was about 31% faster. A reads more clearly; B wins on speed. Which would you pick? #Python #Coding
21
๐Ÿ Python tip: (in) means different things for strings and sets! roles = 'admin editor viewer' print('min' in roles) # True ๐Ÿ˜ฌ roles = frozenset({'admin', 'editor', 'viewer'}) print('min' in roles) # False โœ… A string asks: โ€œdoes this text appear anywhere inside?โ€ A set asks: โ€œis this exact item a member?โ€ #Python #LearnPython #PythonTips #100DaysOfCode #CodeNewbie
1
35
Khalid | Python Tasks Adventurer ๐Ÿ retweeted
๐Ÿ—บ๏ธ My Python book is now available! ๐Ÿ“˜ Python Tasks Adventures 240 total components โ€” tasks, bonus tasks, tips, and exercises covering a wide range of Python concepts. From spy encryption to restaurant queues to Olympic systems. You don't just learn Python. You practice it. โœ… 700+ pages โœ… Beginner to Advanced โœ… Every solution fully explained ๐Ÿ”ฅ Launch price: $34.99 for 2 weeks only โ†’ then $44.99 ๐Ÿ‘‡ amazon.com/dp/B0H7NKVFX6 โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ๐Ÿ“– BEFORE YOU DECIDE โ€” SEE IT FOR YOURSELF ๐Ÿ‘‰ Read a sample task here โ†’ drive.google.com/file/d/1jjXโ€ฆ ๐Ÿ‘‰ Read more samples free on Amazon โ†’ amazon.com/dp/B0H7NKVFX6 One page. Real story. Real code. Real explanation. That's the standard of all tasks. โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” #Python #LearnPython #PythonTips #100DaysOfCode #CodeNewbie
1
1
2
680
Python Quiz ๐Ÿ Before you scroll, check that if one more time. ๐Ÿ You type "no". What does this code print? A) Continuing B) Maybe next time! C) An error Whatโ€™s your pick? #Python #LearnPython #PythonTips #100DaysOfCode #CodeNewbie
1
80
Khalid | Python Tasks Adventurer ๐Ÿ retweeted
๐Ÿ Make It Pythonic Some string tricks look clever at first. Then someone reads the code later and needs a small map. ๐Ÿ˜… Instead of writing: name = "sara" message = ("Hi, " + name.title() + "!").replace("Hi", "Welcome") โœจ Write it the Pythonic way: name = "sara" display_name = name.title() message = f"Welcome, {display_name}!" The second version uses simple steps with clear names. It is easier to read, easier to change, and easier to trust. Make it short when you can, clear when you must. ๐Ÿ #Python #PythonCode #Coding #Programming #CodeNewbie #100DaysOfCode #PythonTips
1
1
82
๐Ÿ Make It Pythonic Some string tricks look clever at first. Then someone reads the code later and needs a small map. ๐Ÿ˜… Instead of writing: name = "sara" message = ("Hi, " + name.title() + "!").replace("Hi", "Welcome") โœจ Write it the Pythonic way: name = "sara" display_name = name.title() message = f"Welcome, {display_name}!" The second version uses simple steps with clear names. It is easier to read, easier to change, and easier to trust. Make it short when you can, clear when you must. ๐Ÿ #Python #PythonCode #Coding #Programming #CodeNewbie #100DaysOfCode #PythonTips
1
1
82
Khalid | Python Tasks Adventurer ๐Ÿ retweeted
"AI wrote your code. Cool. Do you know if it's lying to you?" "AI does everything now, why learn Python?" โ€” sure, and my GPS does everything too, until it confidently sends me into a lake. ๐Ÿš—๐ŸŒŠ AI writes fast. It doesn't always write right. And if you can't read the code, you can't catch the bug โ€” you're just trusting a very confident robot with your project. Python Tasks Adventures โ€” 240 tasks built to make you actually understand what your code does, so you're the one catching AI's mistakes, not the one drowning in them. ๐Ÿ“˜ Free sample: drive.google.com/file/d/1jjXโ€ฆ ๐Ÿ“˜ Amazon: amazon.com/dp/B0H7NKVFX6 #Python #LearnPython #Programming #PythonTips #100DaysOfCode #CodeNewbie #TechBooks #Claude #ChatGPT #Copilot #Gemini
1
117
Khalid | Python Tasks Adventurer ๐Ÿ retweeted
๐Ÿ Python Tip: When to Use Separate ifs Instead of elif Should you use elif or another if? ๐Ÿ If you want both actions to happen when both conditions are true, use two separate ifs. Hereโ€™s a little example ๐Ÿ˜Š number = 6 if number % 2 == 0: print("Divisible by 2!") elif number % 3 == 0: print("Divisible by 3!") Youโ€™ll only see โ€œDivisible by 2!โ€ โ€” Python skips the elif once the first condition is true. But 6 is divisible by both! Give each condition its own if: if number % 2 == 0: print("Divisible by 2!") if number % 3 == 0: print("Divisible by 3!") Use elif to choose one branch. Use separate ifs when multiple branches may need to run. #Python #PythonTips
1
1
2
101
๐Ÿ Python Tip: When to Use Separate ifs Instead of elif Should you use elif or another if? ๐Ÿ If you want both actions to happen when both conditions are true, use two separate ifs. Hereโ€™s a little example ๐Ÿ˜Š number = 6 if number % 2 == 0: print("Divisible by 2!") elif number % 3 == 0: print("Divisible by 3!") Youโ€™ll only see โ€œDivisible by 2!โ€ โ€” Python skips the elif once the first condition is true. But 6 is divisible by both! Give each condition its own if: if number % 2 == 0: print("Divisible by 2!") if number % 3 == 0: print("Divisible by 3!") Use elif to choose one branch. Use separate ifs when multiple branches may need to run. #Python #PythonTips
1
1
2
101
Every Python beginner meets this error at some point: AttributeError: 'NoneType' object has no attribute 'upper' Here is the tricky part. Python points at the line where the None was used, but the real mistake is usually somewhere else. Like this: def make_greeting(name): greeting = "Hello, " + name print(greeting) message = make_greeting("Ada") print(message.upper()) Python points at the last line. But the bug is in make_greeting: it prints the greeting instead of returning it, so it quietly hands back None. Finding that by hand is the "trace back" work every tutorial tells you to do. There is now a small tool that does it for you. Add two lines at the top of your program and the error message gains a few extra lines: which function returned the None, on which line, why, and how to fix it. It's called nonetrace. pip install nonetrace pypi.org/project/nonetrace/ #Python
nonetrace: tells you where a None came from when Python crashes on it When Python crashes on None, it points at the wrong line. nonetrace shows which call returned the None, why, and the fix. pypi.org/project/nonetrace/
41
๐Ÿ Make It Pythonic When you need both the position and the item, do not make Python walk through indexes first. Instead of writing: fruits = ["apple", "banana", "mango"] for i in range(len(fruits)): print(i, fruits[i]) โœจ Write it the Pythonic way: fruits = ["apple", "banana", "mango"] for i, fruit in enumerate(fruits): print(i, fruit) enumerate() gives you two things at once: the index and the item. So the loop becomes easier to read. #Python #PythonCode #Coding #Programming #CodeNewbie #100DaysOfCode #PythonTips
40
Khalid | Python Tasks Adventurer ๐Ÿ retweeted
๐Ÿ Python has two ways to reach the first item: x[0] Normal entrance. ๐Ÿšช๐Ÿ x[-len(x)] The Python snake climbed through the window, crossed the roof, and still arrived at the same place. ๐Ÿ๐Ÿ˜‚ #Python #LearnPython #PythonTips #100DaysOfCode #CodeNewbie
2
85