Reputation: 27
I kinda can't solve this task:
Create variables
Create a while loop that runs as long as the input is all digits Inside the while loop
After the loop exits
Here's my code:
int_num = input("Enter digit: ")
long_num = ""
while int_num.isdigit() != True:
int_num + long_num
int_num = input("You have to enter a DIGIT (integer)!: ")
print(long_num)
I need an advice to solve that with only given information from the task.
Thank you!
Upvotes: 1
Views: 990
Reputation: 62769
I see three problems but since this is probably homework I don't want to just drop out code.
1) int_num + long_num does an addition but throws away the result, you want to save the result.
2) int_num + long_num is in a place where it will only be done if int_num is NOT a digit. I think you want to it if it IS a digit.
3) your while loop exits as soon as you get a non-digit. I don't think that was your intent.
Upvotes: 1