I'm trying to write a simple program that tells you how many digits of e (from mathematics) are equal to your approximation...it works if there are one or more digits incorrect, but if not this pops up:
Traceback (most recent call last):
File "&^%%@%#", line 5, in <module>
while e[c] == ue[c]:
IndexError: string index out of range
I have tried if statements, more while statements and more functions, but it won't work. Here's the code:
e = str(2.7182818284590452353602874713526624977572470936999595)
ue = str(input("Copy in your version of e and this will check it ! "))
c = 0
while e[c] == ue[c]:
if c < len(ue):
c = c + 1
else:
break
print(c - 1)
If I input 2.79
it shows up with 3.
Though if I input, say 2.718
and all digits are correct it says this:
IndexError: string index out of range (Coming from line 5)
(Also this is my first time on Stack Overflow; so cut me some slack.)