For an assignment i am trying to get the results of a form "age" and to add one to that number using python. The form will have users enter their age and result should be their age next year.
Here is what i have thus far:
import cgi
form = cgi.FieldStorage()
name = str(form.getvalue("name"))
age = int(form.getvalue("age"))
print ("""Content-type: text/html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head>
<title>Lab 9</title>
</head><body>
""")
print ("<p>Hello," +name+ ".</p>")
print ("Next year you will be" + str(age+1) + "years old")
print ("</body></html>")
The error i get is
Traceback (most recent call last):
File "/Users/JLau/Documents/CMPT 165/Lab 9/result.py", line 19, in <module>
print ("Next year you will be" + str(age + 1) + "years old")
TypeError: Can't convert 'int' object to str implicitly"
I somehow need to convert the value of age to and "int" to which a number can be added, not sure how to do this.