+ 3

Help… what did I do wrong this time?

Hey everyone… I was trying to do one of the assignments for the while loop section. I have tried several ways, and I left it with what I thought was my best attempt. I don’t understand why I am getting an error.

22nd Jul 2023, 6:03 AM
AniZaTo
11 ответов
+ 7
AniZaTo , > the condition in the loop header is not correct. since we wanted to print all numbers including 1, it should be: while number > 0: ... > the parameter in the print() function should only be the *variable name*, no quotes in this case: print(number) > general: use *indentation with 4 spaces*, this improves the readability of the code.
22nd Jul 2023, 6:18 AM
Lothar
Lothar - avatar
+ 4
AniZaTo , difficult to guess what your current code is. > please link the latest version of your code here.
22nd Jul 2023, 6:19 PM
Lothar
Lothar - avatar
+ 2
AniZaTo 1. We ask for user input to be number 2. We create a loop to print and decrease the number until a condition is met 3. We print out the number 4. We decrease the number by 1 number = int(input()) while number >= 0: print(number) # Same as number = number - 1 number -= 1
22nd Jul 2023, 6:26 AM
Junior
Junior - avatar
+ 1
AniZaTo Can you share your attempt or explain the assignement so we can see
22nd Jul 2023, 6:06 AM
Junior
Junior - avatar
+ 1
AniZaTo What is the program supposed to be doing for the assignment?
22nd Jul 2023, 6:13 AM
Junior
Junior - avatar
0
I tried but I failed miserably. I have to post it on here directly. Sorry, I know I have done it before, but I cannot find the damn file on my Ipad no matter how many times I save it ‘correctly’ I cannot find it under My code Bits when trying to share. The excercise in question is: Time’s Up! # take the number as input number = int(input()) #use a while loop for the countdown while number > 4: print(number) number = number -1
22nd Jul 2023, 6:08 AM
AniZaTo
0
So the instruction reads: Create a timer that will take the number of seconds as input, and countdown to 0. Number + 3 3 2 1 0 (I switched the print command without quotation marks, but it still yealds no results) NO OUTPUT
22nd Jul 2023, 6:21 AM
AniZaTo
0
number = int(input()) while number>-1 print(number) number = number+1
22nd Jul 2023, 2:51 PM
Ashish Shukla
Ashish Shukla - avatar
0
What did you write now?
22nd Jul 2023, 6:23 PM
Ashish Shukla
Ashish Shukla - avatar
0
AniZaTo Replace the input statements with hardcoded values and errors are gone, so i think the problem is that your code ask 2 times for an input, which sololearn (at least mobile version) actually does not support 😅 you must insert all your input values in the input dialog and separate multiple values by a new so suppose you have this simple code that will sum 2 number a and b a = input() b = input() print(a,'+',b,'=',a+b) so you must insert your numbers as following in the input dialog that appears when we first execute our code 15 12 so now, sololearn will make 15 as the value of a and 12 as the value of b Remember this is just a sololearn behavior ☺️
23rd Jul 2023, 11:09 AM
Radi
Radi - avatar
0
Hii
23rd Jul 2023, 5:06 PM
Satyam Kumar
Satyam Kumar - avatar