'how to convert while loop into a function or procedure and pass in new parameters python

Motorbike_price = 3000

print("£",Motorbike_price)

while Motorbike_price > 1000:
    Motorbike_price = Motorbike_price * 0.9
    print("£",Motorbike_price)

how to convert while loop into a function or procedure and pass in new parameters python



Solution 1:[1]

Frankly, it would be better to get some tutorial to learn basis like functions.

def my_function(price):
    while price > 1000:
        price = price * 0.9
        print("£", price)

and don't forget to run it

my_function(Motorbike_price)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 furas