0
The code I was testing worked perfectly in the visual studio, however, by submitting on one of these sites similar to the URI
, that error appeared. I know it is a line reading error, but I could not understand why it is working in visual studio and this site does not work. The code:
def primos_gemeos(num):
valor = False
for n in range(2, num):
if num % n == 0:
break
else:
valor = True
return valor
quantidade = int(input())
lista = []
proxPrimo = None
n = 3
atualPrimo = primos_gemeos(n)
while True:
proxPrimo = primos_gemeos(n + 2)
if atualPrimo and proxPrimo:
lista.append((n, n + 2))
if len(lista) == quantidade:
break
atualPrimo = proxPrimo
n += 2
print(lista)
What will be the entry of the program?
– Woss
Could be any integer
– Berserker
You don’t have to fix it. Depending on where you tested you have to provide the input(s) before running.
– anonimo
The
else
do if you are getting it right? You are trying to submit on those sites like UVA online and URI online?– Danizavtz
That’s right, like these sites and I believe that Else is not the problem, because I tested another approach to check if a number is prime
– Berserker
@Danizavtz Python has the structure
else
to thefor
also, not only for theif
.– Woss