r/Coding_for_Teens • • 2h ago

Can you spot the bug? 2 cookies, and the bill says Rs 22222222222222222222

1 Upvotes

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.)


r/Coding_for_Teens • • 2h ago

Pls check this out

1 Upvotes

r/Coding_for_Teens • • 5h ago

How to plan and build a winning Congressional App Challenge project (starting now before pre-registration opens)

Thumbnail reddit.com
1 Upvotes

r/Coding_for_Teens • • 7h ago

Join hackathon community

Thumbnail
reddit.com
1 Upvotes

r/Coding_for_Teens • • 20h ago

Need advice

Thumbnail reddit.com
1 Upvotes