+ 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)
12 Answers
+ 3
try to change line 1
input = int (input ()) for another variable name because input is a reserve word in python
+ 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
+ 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
+ 1
Still not working
+ 1
I'll share code
+ 1
It is working now I changed name tysm
+ 1
when u use input as a name of a variable it no longer is a bif(built in function
)
+ 1
bullshit
+ 1
Try taking input1 value before the loop
0
input() is a function and therefore can't be used as a variable.
- 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..