Python Forum
Why is this an error? (string and integer)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why is this an error? (string and integer)
#2
Python is not like some other languages like javascript, you need to cast the int to str in order to perform concatenation. Just accept it. This yields to ugly code. That is why more advanced str.format() or f-string are preferred and they offer more advantages. check https://docs.python.org/3/library/string...ing-syntax and string formatting mini-language.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Why is this an error? (string and integer) - by buran - Sep-02-2018, 06:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Question about change hex string to integer sting in the list (python 2.7) lzfneu 1 2,565 May-24-2021, 08:48 AM
Last Post: bowlofred
  How to check if user entered string or integer or float?? prateek3 5 11,406 Dec-21-2019, 06:24 PM
Last Post: DreamingInsanity
  Beginner at Python. Trying to count certain integer from random string of code kiaspelleditwrong 3 2,453 Oct-14-2019, 10:40 AM
Last Post: perfringo
  Error when entering letter/character instead of number/integer helplessnoobb 2 7,134 Jun-22-2019, 07:15 AM
Last Post: ThomasL
  Mixed string,Integer input variable issue maderdash 2 2,789 Nov-06-2018, 09:46 AM
Last Post: snippsat
  string with integer variable within Andy1845c 9 4,982 Mar-12-2018, 10:28 PM
Last Post: Larz60+
  Convert integer to string Maigol 5 5,576 Mar-05-2018, 10:25 PM
Last Post: python_master89
  cannot convert float infinity to integer error despite rounding off floats Afterdarkreader 3 15,271 Dec-15-2017, 02:01 AM
Last Post: micseydel
  why does integer input give error invalid literal for int() PyPhanman 2 6,226 Apr-27-2017, 05:32 AM
Last Post: ndc85430
  Error "an integer is required" in getpass.getuser(). Nirelg 5 5,474 Mar-20-2017, 04:19 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020