473,379 Members | 1,201 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,379 software developers and data experts.

Python Help

Help please i'm new to python !


Script Error
There was an error with your script and it didn't exit properly.

This was its output:

File "/home/kml16/public_html/lab8b/hockey5.py", line 15
<form action="hockey5.py">
^
SyntaxError: invalid syntax
(Error code: 1)

This
Mar 27 '07 #1
4 1135
bartonc
6,596 Expert 4TB
Help please i'm new to python !


Script Error
There was an error with your script and it didn't exit properly.

This was its output:

File "/home/kml16/public_html/lab8b/hockey5.py", line 15
<form action="hockey5.py">
^
SyntaxError: invalid syntax
(Error code: 1)

This
Looks like you are mixing CGI? script into you python script improperly.
It's hard to tell, though, because you have not posted any of the code.
Please read "REPLY GUIDELINES" to learn how to use CODE tags and give a snippet to go on. Thanks for joining the Python Forum on TheScripts.com.
Mar 27 '07 #2
sorry about that.
here's the code
thanks.


Expand|Select|Wrap|Line Numbers
  1. # A program that will predict Hockey scores
  2. import cgi
  3. form = cgi.FieldStorage()
  4. import random
  5.  
  6. print """Content-type: text/html
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  8.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
  9. <html><head>
  10. <title> Predicting Hockey Scores </title>
  11. </head><body>
  12. """
  13.     <form action="hockey5.py">
  14.  
  15.         <p> Enter the first team's name: 
  16.             <input type="text" name="team1" />
  17.         </p>
  18.         <p> Enter the second team's name:
  19.              <input type="text" name="team2" />
  20.         </p>
  21.         <p> Enter the maximum score value: 
  22.              <input type="text" name="maximum" />
  23.         </p>
  24.         <p> Enter the minimum score value:
  25.             <input type="text" name="minimum" />
  26.         </p>
  27.         <p>
  28.         <input type="submit" value="calculate" />
  29.         </p>
  30.     </form>
  31.  
  32.  
  33. if form["maximum"].value == form["minimum"].value:
  34.     print "<p>The scores you have entered are the same values, please refresh the page and try again </p>"
  35.  
  36. minimum = int(form["minimum"].value)
  37. maximum = int(form["maximum"].value)
  38.  
  39. score1 = random.randiant(minimum, maximum)
  40. score2 = random.randint(minimum, maximum)
  41.  
  42. while score1 == score2:
  43.     score1 = random.randint(minimum, maximum)
  44.     score2 = random.randint(minimum, maximum)
  45.  
  46. print "<p>The final score will be: " + form["team1"].value + "(" + str(score1) +")   " + form["team2"].value + "(" + str(score2) + ")</p>"
  47. print """
  48. </body>
  49. </html>
  50. """
  51.  
  52. # It will then print out the final result
  53. print "The final score will be: " + team1 + "(" + str(score1) +")   " + team2 + "(" + str(score2) + ")"
Mar 27 '07 #3
bartonc
6,596 Expert 4TB
sorry about that.
here's the code
thanks.
The code, but no CODE tags...
I don't know the cgi interface, but I can tell you that your tripple quotes may be out of place:
Expand|Select|Wrap|Line Numbers
  1. print """Content-type: text/html
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  3.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
  4. <html><head>
  5. <title> Predicting Hockey Scores </title>
  6. </head><body>
  7.  
  8.     <form action="hockey5.py">
  9.  
  10.         <p> Enter the first team's name: 
  11.             <input type="text" name="team1" />
  12.         </p>
  13.         <p> Enter the second team's name:
  14.              <input type="text" name="team2" />
  15.         </p>
  16.         <p> Enter the maximum score value: 
  17.              <input type="text" name="maximum" />
  18.         </p>
  19.         <p> Enter the minimum score value:
  20.             <input type="text" name="minimum" />
  21.         </p>
  22.         <p>
  23.         <input type="submit" value="calculate" />
  24.         </p>
  25.     </form>
  26. """
Now python wont try to execute "<form action="hockey5.py">" and throw an error at you.
Mar 27 '07 #4
ghostdog74
511 Expert 256MB
sorry about that.
here's the code
thanks.


Expand|Select|Wrap|Line Numbers
  1. # A program that will predict Hockey scores
  2. import cgi
  3. form = cgi.FieldStorage()
  4. import random
  5.  
  6. print """Content-type: text/html
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  8.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
  9. <html><head>
  10. <title> Predicting Hockey Scores </title>
  11. </head><body>
  12. """
  13.     <form action="hockey5.py">
  14.  
  15.         <p> Enter the first team's name: 
  16.             <input type="text" name="team1" />
  17.         </p>
  18.         <p> Enter the second team's name:
  19.              <input type="text" name="team2" />
  20.         </p>
  21.         <p> Enter the maximum score value: 
  22.              <input type="text" name="maximum" />
  23.         </p>
  24.         <p> Enter the minimum score value:
  25.             <input type="text" name="minimum" />
  26.         </p>
  27.         <p>
  28.         <input type="submit" value="calculate" />
  29.         </p>
  30.     </form>
  31.  
  32.  
  33. if form["maximum"].value == form["minimum"].value:
  34.     print "<p>The scores you have entered are the same values, please refresh the page and try again </p>"
  35.  
  36. minimum = int(form["minimum"].value)
  37. maximum = int(form["maximum"].value)
  38.  
  39. score1 = random.randiant(minimum, maximum)
  40. score2 = random.randint(minimum, maximum)
  41.  
  42. while score1 == score2:
  43.     score1 = random.randint(minimum, maximum)
  44.     score2 = random.randint(minimum, maximum)
  45.  
  46. print "<p>The final score will be: " + form["team1"].value + "(" + str(score1) +")   " + form["team2"].value + "(" + str(score2) + ")</p>"
  47. print """
  48. </body>
  49. </html>
  50. """
  51.  
  52. # It will then print out the final result
  53. print "The final score will be: " + team1 + "(" + str(score1) +")   " + team2 + "(" + str(score2) + ")"

bring your triple quotes """ after the "</head><body>" all the way to the last </form>
Mar 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: python-help-bounces | last post by:
Your message for python-help@python.org, the Python programming language assistance line, has been received and is being delivered. This automated response is sent to those of you new to...
3
by: stuart_white_ | last post by:
I've just upgraded from Python 2.3.3 to Python 2.4.2, and, although the new version of Python seems to be running correctly, I can't seem access the help from the interpreter. On Python 2.3.3...
32
by: siggi | last post by:
@Ben Sizer Hi Ben, in January I received your message re Pygame and Python 2.5: As a Python (and programming ) newbie allow me a - certainly naive - question:
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.