I have a program that will count up to a number. When I assign the variable x to a number manually, it works. When I use an input, the time limit is exceded. What is going wrong and how do I avoid this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I have a program that will count up to a number. When I assign the variable x to a number manually, it works. When I use an input, the time limit is exceded. What is going wrong and how do I avoid this?

9th Nov 2016, 12:28 AM
Zach Miller
7 Answers
+ 2
Python input() is a string. You're probably not converting input to int(). int(input("What value for x?"))
9th Nov 2016, 3:28 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
x=(int)(input("Enter number ")) num=0 while num < x: print (num) num = num +
10th Nov 2016, 9:01 AM
Gurpreet Singh
Gurpreet Singh - avatar
0
can you show me your code?
9th Nov 2016, 1:22 AM
Gurpreet Singh
Gurpreet Singh - avatar
0
guys how do i write a program and it works using python, or what do i require
9th Nov 2016, 5:47 AM
paul mwengei
paul mwengei - avatar
0
guys how do i write a program and it works using python, or what do i require
9th Nov 2016, 5:47 AM
paul mwengei
paul mwengei - avatar
0
x = 56 y = 0 while(1 == 1): y = y+1 print("Guessing",y) if(x == y): print("Number is",y) break
9th Nov 2016, 12:09 PM
Zach Miller
0
Thx guys
11th Nov 2016, 1:07 AM
Zach Miller