pfz0 = ["","centi","milli","micri","nani","pici","femti"] # z for zeta
illion = ["llion","illion"]
a0_ni = input("first 3 digits:")
a0 = int(a0_ni) # femti
b0_ni = input("next 3 digits:")
b0 = int(b0_ni) # pici
c0_ni = input("next 3 digits :")
c0 = int(c0_ni) # nani
d0_ni = input("next 3 digits :")
d0 = int(d0_ni) # micri
e0_ni = input("next 3 digits:")
e0 = int(e0_ni) # milli
f0_ni = input("next 3 digits :")
f0 = int(f0_ni) # centi
zl = [f0,e0,d0,c0,b0,a0]
if isinstance(a0,int) and isinstance(b0,int) and isinstance(c0,int) and isinstance(d0,int) and isinstance(e0,int) and isinstance(f0,int) and a0 < 1000 and b0 < 1000 and c0 < 1000 and d0 < 1000 and e0 < 1000 and 10 < f0 < 1000:
print(pfz0[int(zl.index(a0)) + 1] + pfz0[zl.index(b0) + 1] + pfz0[zl.index(c0) + 1] + pfz0[zl.index(d0) + 1] + pfz0[zl.index(e0) + 1] + illion[0])
elif zl == [0,0,0,0,0,0]:
print("zero")
print("10^-inf")
else:
print("error")
here's the code. for some reason, it keeps returning the wrong result. The result it gives is what you would get if zl.index(literally anything in zl) = 0. but it's very clearly not. This only happens if I input repeated numbers for a0,b0,c0,d0,e0,f0(e.g. 555,555,555,555,555,555)otherwise, the code works fine. What's the problem?
Whenever I input the same repeated digit for a0,b0,c0,d0,e0,f0, instead of getting the following:
femtipicinanimicrimillicenti
[this is what I should get by the way]
I get this instead:
centicenticenticenticenticenti
(which is NOT what I should be getting)
I can't think of anything to fix this. Please help
I am very confused. Tbh I couldn't think of anything to try so I just gave up and came here. All I kind of did is just check for typos, but there wasn't any. I checked about 15 times by now and not a single typo. I've checked my indentation, and everything is properly indented.
The program is working exactly as you told it to, but you have a misunderstanding about how index()
works. It always returns the first matching index. [555,555,555,555,555,555].index(555)
will always return 0
.