If you just want to print the value of the variable numero1
, I do not see it necessary to use format
just print the variable
numero1 = 1
#Imprimimos el número
print "Desde el numero " , numero1
#Incrementamos para iniciar en 2
numero1 = numero1 + 1
while True:
# si es igual a 10 matamos el ciclo
if numero1 == 10:
print "hasta el numero ", numero1
break
#caso contrario imprimimos el número e
#incrementamos la variable
print numero1
numero1 = numero1 + 1
Although to improve the reading a bit and not change much and work with any start or end, could have declared 2 variables, inicio
and final
and iterate through a for
, with range(inicio,final):
that is, it will start with the start value and end when it reaches the end value, this is similar to the typical i < n
of the classic for
, for this case it would be inicio < final
inicio = 1
final = 10
#Imprimimos el número
print "Desde el numero " , inicio
#Incrementamos para iniciar en 2
inicio+=1
for x in range(inicio,final):
print x
print "Hasta el numero " , final