1,105,391 Community Members

Generating random background colors in HTML using Python

Member Avatar
lfmconsummates
Newbie Poster
8 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I'm trying to have HTML generate random background colors using Python. What I have so far is:
print "<body bgcolor='%s'>" % choice
what python code should follow?

Member Avatar
lfmconsummates
Newbie Poster
8 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I was also thinking of using a list of colors, like this:
bgcolor = ["red","blue","silver","green","yellow"]
but again, i'm unsure of how to use the random function with this list

Member Avatar
pyTony
pyMod
6,103 posts since Apr 2010
Reputation Points: 818 [?]
Q&As Helped to Solve: 1,056 [?]
Skill Endorsements: 42 [?]
Moderator
Featured
 
1
 

see random.choice

Question Answered as of 2 Years Ago by pyTony
Member Avatar
lfmconsummates
Newbie Poster
8 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks that did it

Member Avatar
prerakmody
Newbie Poster
3 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi!I was wondering if I could know how to implement HTML along with python,
Do i simply use IDLE and enter (html+python)
OR do I have to call library packagesetc??
Thank You

Member Avatar
pyTony
pyMod
6,103 posts since Apr 2010
Reputation Points: 818 [?]
Q&As Helped to Solve: 1,056 [?]
Skill Endorsements: 42 [?]
Moderator
Featured
 
0
 

Do you mean templating systems?

Member Avatar
prerakmody
Newbie Poster
3 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Yes,I mean templating systems.
So how could I use IDLE to start typing HTML code like this
<table>
<%
for item in items:
%>
<tr>
<th>Name</th>
<td><%= item.name %></td>
</tr>
<%
%>
</table>

Member Avatar
prerakmody
Newbie Poster
3 posts since Mar 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Which templatng engine should I be using,to generate HTML pages?

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: