Python Forum
Converting String to Integer Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting String to Integer Python
#4
(Aug-02-2019, 07:31 PM)ichabod801 Wrote: int('1') does not change the value a is assigned to. It creates a new value and converts that. You need to reassign the new value to a. And you should convert a, not a new value, to make sure it works if the value of a is changed.

Thanks! This helped.

To solve the problem, I simply did as ichabod801 instructed. I changed the code
a = "1"
b = 2
int("1") 
print(a + b)
to this code:

a = "1"
b = 2
a = int("1") 
print(a + b)
Thanks Again!
Reply


Messages In This Thread
Converting String to Integer Python - by Johnny1998 - Aug-02-2019, 07:23 PM
RE: Converting String to Integer Python - by Johnny1998 - Aug-02-2019, 07:40 PM
RE: Converting String to Integer Python - by Yoriz - Aug-02-2019, 07:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using an integer to manipulate a string/text variable rexyboy2121 1 1,751 Apr-22-2020, 01:37 AM
Last Post: michael1789
  Trouble converting a string into an int DreDigital 2 1,647 Jan-29-2020, 09:41 PM
Last Post: DreDigital
  Determine if string is integer jrodencal 12 4,152 Oct-15-2019, 01:39 PM
Last Post: jefsummers
  Converting pseudocode to Python qwertyK 3 23,691 Oct-24-2017, 01:41 PM
Last Post: qwertyK

Forum Jump:

User Panel Messages

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