python - Adding 1 to an integer value gives TypeError -
I know that this is probably a super simple answer but I have some problems with basic programming questions.
I am trying to program for Python so that in this case can add a specific variable "age" + 1 This is not working
import cgi form = cgi.FieldStorage () "content type: text / html & lt;! DOCTYPE html public" (); Text1 = form.getvalue ("name") text2 = int (form.getvalue ("age")) # Print HTTP / HTML Header Print ("" "- //W3C / DTD XHTML 1.0 Stronger // N "" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Head & gt; & lt; Title & gt; A CGI Script & Lt; / title & gt; & lt; / head & gt; & lt; body & gt; "" ") Print (" & lt; p & gt; hello, "+ name +". & Lt; / p & Gt; ") Print (" & lt; p> Next year you will be of "+ str (age) + 1" year; ") Print (" & lt; / body & Gt; & lt; / html & gt; ")
You" + " String assembly and variable length Mixing it in the form of a letter.
It should be str (age + 1) . age = 26 print ("this The year is "+ str (age) +" year old.) Print ("Next year," + str (age + 1) + "year old"). Tested on
Comments
Post a Comment