Coding Error 😭

I keep getting the error: Import block is un-sorted or un-formatted with my code:

import math
import os
import random
import re
import sys

class VendingMachine:
    def __init__(self, num_items, item_price):
        self.num_items = num_items
        self.item_price = item_price

    def buy(self, req_items, money):
        if req_items > self.num_items:
            raise ValueError("Not enough items in the machine")

        required_amount = req_items * self.item_price

        if money < required_amount:
            raise ValueError("Not enough coins")

        self.num_items -= req_items
        change = money - required_amount
        return change

if __name__ == '__main__':
    num_items, item_price = map(int, input().split())
    machine = VendingMachine(num_items, item_price)

    n = int(input())
    for _ in range(n):
        num_items, num_coins = map(int, input().split())
        try:
            change = machine.buy(num_items, num_coins)
            print(change)
        except ValueError as e:
            print(e)

Vending Machine - Replit is the repl

It is just the pywright-extended being annoying.

4 Likes

Thank you!

1 Like

Yeah I was about to say, there’s no errors.

Btw, can I pre-order a vending machine from you to keep in my house?

2 Likes

This is probably the fastest a post has been solved.

1 Like

Ok now check out my repl (shameless plug lmao)

-Vending Machine - Replit

3 Likes

Its actually kinda fun XD

is pywright a new addition to the replit coding interface (like some sort of styler that doesn’t let you exec code without good styling lol)? Cuz I popped on replit for the first time in a century and it looked like completely different @CoderElijah

1 Like

I think so. It is now some picky perfectionist program that says mean things.

3 Likes

this is just another bad move for replit. As a package creator (I made replit-bot which went semi-viral but also a lot of other things), you need to make sure when making things for distribution, everything needs to be opt-IN, not opt-OUT since people won’t know squat about how to turn it off

1 Like

it’s not an error :woman_facepalming: it’s a warning

I think it could be the fact that there seems to only be one newline between the imports and the class VendingMachine:, but I could be wrong

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.