We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,259 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Generating random background colors in HTML using Python

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?

3
Contributors
7
Replies
3 Days
Discussion Span
1 Year Ago
Last Updated
8
Views
Question
Answered
lfmconsummates
Newbie Poster
8 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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

lfmconsummates
Newbie Poster
8 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

see random.choice

pyTony
pyMod
Moderator
6,310 posts since Apr 2010
Reputation Points: 879
Solved Threads: 987
Skill Endorsements: 26
Question Answered as of 1 Year Ago by pyTony

Thanks that did it

lfmconsummates
Newbie Poster
8 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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

prerakmody
Newbie Poster
3 posts since Mar 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
pyTony
pyMod
Moderator
6,310 posts since Apr 2010
Reputation Points: 879
Solved Threads: 987
Skill Endorsements: 26

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>

prerakmody
Newbie Poster
3 posts since Mar 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

prerakmody
Newbie Poster
3 posts since Mar 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0793 seconds using 2.68MB