Need help understanding python code

0 votes

Not very clear how these values are derived and why it is not going above 2888

values = []
for 
i 
in 
range(1000,3001):
s = str(i)
if 
(int(s[0])%2==0) 
and 
(int(s[1])%2==0) 
and 
(int(s[2])%2==0) 
and 
(int(s[3])%2==0):
print(
values.append(s))
print (
","
.join(values))
Feb 19, 2019 in Python by Ronny
523 views

1 answer to this question.

0 votes

In this particular code, I think you are printing those numbers in which all the digits are even. So, till 2888 all the digits in this number i.e 2,8,8,8 are even number. After 2888 it is 2889, 2890 and 2891 etc, there is an odd number which is 9 and there will be one odd digit in every number after 2888 till 3001 which will not get printed.

answered Feb 19, 2019 by Omkar
• 69,220 points

Related Questions In Python

0 votes
1 answer

Need help with Tkinter window formatting using Python

Tkininter comes with the columnspan argument to span the labels ...READ MORE

answered Sep 7, 2018 in Python by aryya
• 7,460 points
888 views
+1 vote
1 answer

Need some help with Python memory leaks

As far as best practices, keep an ...READ MORE

answered Nov 26, 2018 in Python by Nymeria
• 3,560 points
994 views
0 votes
1 answer

Need help installing easy_install in Python 2.7.1 on Windows 7

That tool is part of the setuptools ...READ MORE

answered Dec 26, 2018 in Python by Nymeria
• 3,560 points
1,199 views
0 votes
1 answer

Need help extracting a schema to make use for an avro file in Python

Hi, nice question. So what I daily use ...READ MORE

answered Jan 10, 2019 in Python by Nymeria
• 3,560 points
4,976 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,071 views
+1 vote
3 answers

PYTHON: Who could help?

A quick solution is to use the collections ...READ MORE

answered Nov 26, 2018 in Python by Omkar
• 69,220 points
891 views
0 votes
2 answers

Help me solve the code

The fetchone() method fetches the result of ...READ MORE

answered Jan 9, 2019 in Python by Omkar
• 69,220 points
1,017 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP