I have got to shorten the number that comes out of a calculation down to the smallest possible whilst being easy to read, such as 999,000 - 999k, and 999,000,000 - 999m.
I believe I have the code I need but I am not sure how I am meant to implement it into my code
while True:
bands = input("Please enter your first band colour: ").upper()
print("")
if bands== 'BLACK':
print("The colour black may only be entered in the 2nd or 3rd colour slots.")
continue
bands1 = input("Please enter your second band colour: ").upper()
print("")
bands2 = input("Please enter your third band colour: ").upper()
print("")
print("Ohm value of resistor:", (dict[bands]*10 + dict[bands1]) * (10 ** dict[bands2]),"Ω", )
def print_prefix(value):
prefix=('', 'K', 'M', 'G')
i = 0
if (1000<bands//1000**i):
i=i+1
print(str(value/(1000**i))+prefix[i])
I expect the result of it to be shortened so a prefix can be added