TypeError: Can't convert 'int' object to str implicitly *Python* -
For an assignment, I am trying to get the results of an "age" and using that python I'm trying to add. Users in the form must enter their age and the results should be of their age next year.
Even I have so far:
import cgi form = cgi.FieldStorage () name = rr (form.getvalue ("name")) Age = int (form.getvalue ("age")) Print ("" "" Content Type: Text / html "! DOCTYPE html public" - // W3C // DTT XHTML 1.0 Strongly //n "" http: /www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> & gt; HTML & gt; & gt; Head & gt; Title & gt; Lab 9 & lt; print ("& lt; P & gt; Hello, "+ name +". & Lt; / p & gt; ") Print (" Next year you will be "+ str (age) Error is found
traceback (most recent call Last: You "+ str (age + 1) +" next year "print" in the file "/ user / jlu / document / CMPT165 / lab 9 / result", in line 19, "Old of year") type: error: 'int' object can not be converted into a strip " I need some way to change the value of the age and" Int "in which any number can be added, is not sure how to do it.
This can not be a code you are running.
Check the following tests.
& gt; & Gt; & Gt; Age = 20> & Gt; & Gt; Print (next year you will be "+ str (age + 1) +" old of years ") next year you will be 21 years old gt; & Gt; Era = '20' & gt; & Gt; & Gt; Print ("Next year you will be + str (age + 1) +" old of years ") Traceback (most recent call final): File" & lt; pyshell # 4 "gt; In the print line, & lt; Module & gt; Print ("Next year you will be + str (age + 1) +" year old ") Type: Error: The 'integer' object can not be converted to a strip This error will be detected if is a string
Please add a line with
print (type (age)) See more results.
Comments
Post a Comment