About 102,000 results
Open links in new tab
  1. Python strings and integer concatenation - Stack Overflow

    I want to create a string using an integer appended to it, in a for loop. Like this: for i in range(1, 11): string = "string" + i But it returns an error: TypeError: unsupported oper...

  2. How can I concatenate a string and a number in Python?

    Aug 8, 2011 · Since Python is a strongly typed language, concatenating a string and an integer, as you may do in Perl, makes no sense, because there's no defined way to "add" strings and …

  3. How can I concatenate two integers in Python? - Stack Overflow

    Oct 11, 2012 · This is not the problem requested. for example, it would not work if you try to concatenate 10 and 200, it would result in 1200 instead of 10200. you could use def f(x, y): …

  4. python - How can I concatenate str and int objects ... - Stack …

    As a rule, Python doesn't implicitly convert objects from one type to another 1 in order to make operations "make sense", because that would be confusing: for instance, you might think that …

  5. python - Print Combining Strings and Numbers - Stack Overflow

    Aug 18, 2012 · To print strings and numbers in Python, is there any other way than doing something like: first = 10 second = 20 print "First number is %(first)d and second number is …

  6. Concatenating string and integer in Python - Stack Overflow

    Python is an interesting language in that while there is usually one (or two) "obvious" ways to accomplish any given task, flexibility still exists. s = "string" i = 0 print (s + repr(i)) The above …

  7. Concatenate string and int in Python 3 .4 - Stack Overflow

    Yeah, there are some differences between Python 2 and 3, which is the reason that Python 2 is still used today. The Python wiki has a page on the subject. For learning purposes, it doesn't …

  8. python - How to resolve TypeError: can only concatenate str (not …

    message is now an int type, so for char in message: causes TypeError: 'int' object is not iterable. message is converted to int to make sure the input is an int. Set the type with str() Only …

  9. How to concatenate an int with a string in Python?

    Jun 23, 2021 · Python: concatenate string and int in a loop. 0. How to concatenate integers variables as a string? 0. Q ...

  10. Convert integer to string in Python - Stack Overflow

    Jun 23, 2019 · For Python 3.6, you can use the f-strings new feature to convert to string and it's faster compared to str() function. It is used like this: It is used like this: age = 45 strAge = f'{age}'