0
If I run this code, it will give a string list:
So that I can not make the average number correctly (since it is in string). What can I do to have the number printed in float/int?
Does this "bug" happen only with Python.3x? What would happen if I migrated to 2x.? It would print in float?
vet_aluno = [0]*2
for i in range(2):
vet_aluno[i] = input ("Digite o nome do(a) aluno(a): ")
vet_nota1 = [0]*2
for k in range(2):
vet_nota1[k] = input("Digite a nota de " + str(vet_aluno[0]) + ": ")
vet_nota2 = [0]*2
for a in range(2):
vet_nota2[a] = input("Digite a nota de " + str(vet_aluno[1]) + ": ")
#Calculando a média
media1 = media(vet_nota1[0],vet_nota1[1])
media2 = media(vet_nota2[0],vet_nota2[1])
In that case it would be more convenient and practical to use Python2?
– Kenneth Anderson
The two are equivalent at this point. In Python3 you can also easily interpret the input as float, as shown, and if the user does not enter a float in Python2, you will also have problems if you do not check that what was actually typed is the float, then that shouldn’t be a criterion for deciding between one and the other. The best would be to use Python3 whenever possible, since it is the latest version. More and more people will stop supporting Python2 in the future.
– luislhl