I have finally got the patience to use Python again and I am trying some math stuff to get back in, but I am now trying to make a Python script and it came up with the “float’ object is not subscriptable’ error. Again, I have just got back into Python and I have no clue what this means. It may be obvious, but all I am seeing on stackoverflow is people telling others how to fix their specific code rather than explaining what it means so I don’t know what could be causing it. All I know is that it has something to do with the fact Pi is a decimal number (floating point number??) but I don’t see why it shouldn’t be able to get nth character of it.
It comes up for “if pi[digit] == digitChar:” on line 11. Here is my code:
pi = 0 divideBy = 1 digit = 1 digitChar = 3 digitOccurance = 1 while True: pi = pi - 4 / divideBy divideBy = divideBy + 2 pi = pi + 4 / divideBy divideBy = divideBy + 2 if pi[digit] == digitChar: digit = digit + 1 digitOccurance = 0 print(digitChar) else: digitChar = pi[digit]
The last bit of code is basically to stop the spam and to just show one digit at a time. It is meant to get the [digit] digit of ‘pi’ and test if it was the same as the previous one. If it is, it moves along a character and prints the Character [digitChar].
Thanks so much for the help in advance!