r/Coding_for_Teens • u/abhiramreddykalluru • 2h ago
Can you spot the bug? 2 cookies, and the bill says Rs 22222222222222222222
A café's bill machine charged a customer Rs 22222222222222222222 for 2 cookies. It should say Rs 40. Here's the code:
```python
cookie_price = 20
cookies = input("How many cookies: ")
total = cookie_price * cookies
print("Total: Rs", total)
```
The cashier typed 2. Where does it go wrong, and why that weird number?
Put your answer in a spoiler if you can so others can try too. I'll explain it in the comments later.
(I made this one for a free Python practice site I'm building, tryline.dev, where every lesson ends with a bug like this. Mostly curious whether it's too easy or too hard for people just starting out.)