Counter object

📋 โจทย์

คลาส Counter มี value เริ่ม 0 เมธอด inc(self) เพิ่ม 1 และ get(self) คืนค่า — รับจำนวนครั้ง n แล้ว inc n ครั้ง พิมพ์ get()

⚠️ ข้อจำกัด

n ≥ 0

📝 ตัวอย่าง

ตัวอย่างที่ 1
Input:
3
Output:
3
🔓 ดูเฉลย
class Counter:
    def __init__(self):
        self.value = 0
    def inc(self):
        self.value += 1
    def get(self):
        return self.value
c=Counter()
for _ in range(int(input())):
    c.inc()
print(c.get())
🐍 main.py

กด Run เพื่อรันโค้ด หรือ ตรวจคำตอบ เพื่อตรวจ test cases