Search code examples
pythonnumbers

input function : python


counttonum = 1
countnum = input("[•] Provide A Number :")
 while counttonum < countnum:
   print("[", counttonum, "] : Number = ", counttonum)
   counttonum +=1

I was trying to make a counting tool that counts up to the provided number from the “input()” function.

For example: providedNumberFromInput = 5 output = 1 2 3 4 5

And it’ll stop if the provided number is reached. Please help me.


Solution

  • You are very close to solution. Problem is that input() returns value as string so you will need to convert it. And also if you want to include entered number use <= instead of <

    while counttonum <= int(countnum):