@bishabkuma7 A habit that helps on day 1: after each example, change one thing and predict the output before you run it. Try this:
x = "5"
print(x * 2)
Guess first, then work out why it prints 55 and not 10.
@OlaideAtechsis@sqicict One type conversion catch: input() always returns a string, so age = input() then age + 1 throws a TypeError.
age = int(input("Age: "))
If someone types "abc" that still errors, which makes try/except a good next topic.
@suraj_biya63760 Hangman is a great one for sets. Tracking guesses in a set makes the checks one line each:
if letter in guessed: print("Already tried that")
guessed.add(letter)
if set(word) <= guessed: print("You win")
<= means every letter of the word has been guessed.
@iamkenny_co Fun build. One thing worth adding: fetch doesn't throw on a 404, so a mistyped city fails quietly.
const res = await fetch(url);
if (!res.ok) throw new Error("City not found");
Then show that message on the page instead of a blank card.
@kamiludeenao Nested ifs get easier when you flip them into early exits:
if not member: return "no plan"
if days_late > 30: return "suspended"
return "active"
Each check handles one case and leaves, so you never go three levels deep. Run it in small pieces before it's finished, too.
@VishalMistry_77 One GROUP BY trap worth knowing early: to filter on an aggregate, use HAVING, not WHERE.
SELECT class, AVG(score) FROM grades GROUP BY class HAVING AVG(score) > 80;
WHERE filters rows before grouping. HAVING filters the groups after.
Answer: 1,23
+ on two arrays doesn't add them. JS turns each array into a string first:
[1, 2] becomes "1,2"
[3] becomes "3"
Then + joins the strings: "1,2" + "3" = "1,23"
Want a merged array? Use [...[1, 2], ...[3]]
@ermes968 True, and the fastest way through that 80 percent: print the value right before the line that breaks. print(type(x), x) in Python or console.log(typeof x, x) in JS. Most beginner bugs are a value that isn't what you expected.
@EmmanuelMojiboy Nice converter. Next step: put miles = float(entry.get()) inside try/except ValueError, so typing letters shows a friendly message instead of a traceback. f"{km:.2f}" then keeps the result to two decimals.
@anasraza07 Good list. The return value that surprises people most: push returns the new length, not the array. So with arr = [1, 2], arr.push(3) gives 3. And slice copies while splice changes the original.
@mariusdevz Congrats on shipping it. Quick polish pass: open Chrome DevTools, run Lighthouse, and fix the accessibility items first. Missing alt text and low-contrast text are the usual ones, and each fix takes a minute.
@ykPruthvi Great start. Two upgrades for the calculator: use a = float(input("First number: ")) so 2.5 works, and check if b == 0 before dividing so it prints a message instead of crashing with ZeroDivisionError.
@justicegoldman A common cause of DOM ordering bugs: appendChild moves an element that already exists instead of copying it, so it jumps to the end. To place it exactly, use parent.insertBefore(newEl, refEl), or refEl.before(newEl).
@Alexuixd Fun project. One fix that saves players a lot of misses: clean the guess before comparing. guess = user_input.strip().title() turns " new york " into "New York", so stray spaces and lowercase typing still match.
@symplyhanney Nice one. Next step, to see the full duplicate rows and not just the counts: SELECT * FROM users WHERE email IN (SELECT email FROM users GROUP BY email HAVING COUNT(*) > 1). Same GROUP BY, now used as a filter.
@A_Adebayoor Good news: JavaScript has no separate integer type. 5 and 5.5 are both Number. To check for a whole number, use Number.isInteger(5), which gives true, while Number.isInteger(5.5) gives false.
@Tech_code_beast Solid order. One tip: build a small project in plain HTML, CSS and JavaScript before React, like a to-do list that saves to localStorage. React makes much more sense once you've updated the DOM by hand.