RegsonDR

TypeError: can only concatenate str (not "NoneType") to str

flask Icon

TypeError

can only concatenate str (not "NoneType") to str

An unhandled exception occurred on line 7
5
@app.route('/')
6
def hello_world():
7
    name = "Rd"+ None
8
    return 'Hello '+name+'!'

Solution

Test post: 
I was trying to concatenate a string and 'None' together. I have changed the value of None to an empty string "" instead!            
Jan 27, 2021 Anyone

2 replies


Metro

I think the use of "+" isn't really ideal in this case..

Metro

' '.join(str Vals) should do the work better


Install the browser extension

Found this solution helpful? Try our extension for quick solutions to your Flask errors.

Chrome logo Add to Chrome - It's free