473,322 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

'Spam' and 'Eggs' (the list) [solved]

I need to generate a list containing 500 words. Each word should be, 'Spam', unless the index of the word in the list is a multiple of 3 or 5. In which case the word should be, 'eggs'. The index of the first word is 0.

Anyone know where I should start?
Thanks in advance for the help.
Nov 11 '06 #1
4 1863
Your question is not clear enough. State an EGGsample of what you want to start with, and what you want to end with.
Nov 11 '06 #2
Sorry...I wrote the question exactly as my homework ask it. Maybe thats why I feel lost:

I guess I should have a list ['eggs', 'Spam', 'Spam', 'eggs', 'Sam', 'eggs', 'eggs', 'Spam', 'Spam', 'eggs', 'eggs', 'Spam', 'eggs', 'Spam', 'Spam', 'eggs', 'spam',.......]
but I need to find out how to write that I want the multiples of 3 and 5 to say eggs and all the rest to say Spam.

Hope that is clearer........
Nov 11 '06 #3
Expand|Select|Wrap|Line Numbers
  1. my_list=["spam"]*500
  2. for i in range(500):
  3.     if i%3==0 or i%5==0:
  4.         my_list[i]="eggs"
  5. print my_list
  6.  
That should just about do it.
Nov 11 '06 #4
Thank you so much! I have been working on that question for the last 2 hours. Your response works perfect!
I really appreciate the help!!!!
= )
Nov 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: seberino | last post by:
I have been using distuils for a while and was wondering when Python Eggs (new project) is better? So basically Python Eggs precompiles and compresses binaries for you so you just have to load...
5
by: seberino | last post by:
It appears that apps distributed as Python Eggs are either a single compressed blob in site-packages directory or a directory under site-packages directory. Is this ALWAYS true? So by just...
3
by: Mike Orr | last post by:
I'm trying to install a program that uses Durus on a server. It appears that if a Python program uses eggs, it creates a ~/.python-eggs/ directory, so the home directory must be writeable. This...
0
by: Jeff Rush | last post by:
Eggs are important to Python and will become more so over the next few years, if understood and embraced by the community. They are a key competitive feature - I've been asked so many times what...
1
by: Harry George | last post by:
"eggs" are wonderful for no-hassle get-all-the-dependencies. However, they can trigger hands-off downloads from various sites. This is Bad News for corporate environments in which every download...
2
by: nisimura | last post by:
Hi, I'm trying to use MySQL Python module on Cygwin. Since there is no binary package, I compiled MySQL C client library and Python module (http://sourceforge.net/projects/mysql-python)...
0
by: KLEIN Stephane | last post by:
Hi, first, I think that my question is generalist and don't impact only zopeproject and/or Paste package. Instance, when I trace (debug) some scripts, its name is "/home/harobed/...
5
by: jryanfallon | last post by:
I am trying to write a program to sort eggs, extra eggs are discarded the program must have a pop up box for enter the eggs box type extra large - 12 dozen (144 eggs) large - 6...
4
by: Alia Khouri | last post by:
Can we open up the discussion here about how to improve setuptools which has become the de facto standard for distributing / installing python software. I've been playing around with ruby's gems...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.