Aug-19-2018, 08:02 AM
This is the code I wrote initially,
However, it gives TypeError : can only concatenate str (not "list") to str
So I modified the code this way:
And now its working fine, but I don't understand why
It would be great if you could explain this to me.
Thanks
1 2 3 |
print ( "Once upon a time, 5 men were walking by the forest" ) warriors = [ "Kevin" , "Casper" , "Nick" , "Jim" , "Napolean" ] print ( "The names of these men were: " + (warriors)) |
So I modified the code this way:
1 2 3 |
print ( "Once upon a time, 5 men were walking by the forest" ) warriors = [ "Kevin" , "Casper" , "Nick" , "Jim" , "Napolean" ] print ( "The names of these men were: " + str (warriors)) |
It would be great if you could explain this to me.
Thanks