2
I was doing some exercises on the Internet and I came across the following: create a program that reads the first term and the reason and calculate the umpteenth term of this P.A. I did the program but I was in doubt "and if I inserted a decimal number instead of the reason or the first term?".
a1 = int(input('Insira o valor do primeiro termo: '))
r = int(input('Insira o valor da razão: '))
pa = a1 + (9 * r)
for c in range(a1, pa, r):
print(c)
The problem is replacing "int" with "float". I get this error:
Traceback (Most recent call last):
File "c:/Users/ricar/Desktop/curso-python/teste/testes.py", line 4, in for c in range(a1, pa, r): Typeerror: 'float' Object cannot be Interpreted as an integer
I had no idea that the range structure only works with integers. Thanks for the clarification.
– Ricardo Passos