[Tutor] (no subject)

Alan Gauld alan.gauld at yahoo.co.uk
Sun Jul 26 20:10:12 EDT 2020


On 26/07/2020 23:15, sophia lore wrote:
> Create a program that iterates using a *for loop* over all values of
> list_mod. The program must check each value and append the string "True" to
> the list result if the value is even or append the string "False" to the
> list result otherwise.
> In [ ]:
> 
> ### GRADED
> 
> list_mod = list(range(1,15))
> result = []

There are several ways to do this depending on your level of knowledge.
But given you are struggling I'll assume we have to stick to the basics.

All you need is a for loop and a single if/else.

> I have been working on this question for class for two days. I have tried
> numerous combinations of if/else statements in the for loop to achieve the
> outcome requested. All of the code I have tried returns errors. I can't
> seem to grasp how to set this up. Any help would be appreciated.

It will help us enormously if you post your code and the full
error message since the errors contain a lot of useful
information (once you learn how to decipher them!)

But without code we would just be guessing. And we won't do
your homework for you, we can only give hints and direction.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list