+ 3

Why this code gives no output

input = int(input()) i=0 sum=0 while i<input: input1 = int(input()) if input1%2==0: sum=sum + input1 print(sum)

6th Jul 2020, 4:04 PM
Shivam Rawal
14 ответов
+ 3
try to change line 1 input = int (input ()) for another variable name because input is a reserve word in python
6th Jul 2020, 4:11 PM
Emanuel Maliaño
Emanuel Maliaño - avatar
+ 2
You aren't increasing i. The code creates an infinite loop. You are also requesting input many times, so be careful - SoloLearn requires all input to be entered BEFORE you run the code. Finally, I'd suggest you rename the first "input" variable. Never name your variables with a name of a method/function. Shivam Rawal I made edits for all the needed fixes
6th Jul 2020, 4:08 PM
Artem Khaiet
Artem Khaiet - avatar
+ 2
2,6,9 means it takes 2 input if those inputs are even number so it will add them if first input is 3 it takes more 3 inputs and add even numbers if input is 2 6 9 ans is 6 as 9 is odd
6th Jul 2020, 4:17 PM
Shivam Rawal
+ 1
Still not working
6th Jul 2020, 4:10 PM
Shivam Rawal
+ 1
I'll share code
6th Jul 2020, 4:10 PM
Shivam Rawal
6th Jul 2020, 4:11 PM
Shivam Rawal
+ 1
It is working now I changed name tysm
6th Jul 2020, 4:14 PM
Shivam Rawal
+ 1
when u use input as a name of a variable it no longer is a bif(built in function )
7th Jul 2020, 3:56 AM
Jeremy Cheung
Jeremy Cheung - avatar
+ 1
bullshit
8th Jul 2020, 3:03 AM
Jeremy Cheung
Jeremy Cheung - avatar
+ 1
Try taking input1 value before the loop
8th Jul 2020, 9:10 AM
Rahid Ahmed
Rahid Ahmed - avatar
0
input() is a function and therefore can't be used as a variable.
6th Jul 2020, 4:36 PM
shubham kumar
shubham kumar - avatar
- 1
Why this code gives no output input = int(input()) i=0 sum=0 while i<input: input1 = int(input()) if input1%2==0: sum=sum + input1 i=i+1 print(sum) You have to increase the value of i so that while loop at one point it ends and compiler goes to print function and runs that command,, you forgot to increase the value of i..
7th Jul 2020, 4:21 AM
Nelakurthi Vijay Chowdary