Python Forum
converting string object inside a list into an intiger - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: converting string object inside a list into an intiger (/thread-25409.html)



converting string object inside a list into an intiger - bwdu - Mar-29-2020

Hi,guys!

import sys
a = sys.argv
a.remove('C:\\Users\\USER\\Desktop\\app\\as4t.py')

print(a)

C:\Users\USER\Desktop\app>as4t.py 1 2 3
['1', '2', '3']

How can i make that output [1, 2, 3]?


converting string object inside a list into an intiger - bwdu - Mar-29-2020

Hi guys!

import sys


a = sys.argv
a.remove('C:\\Users\\USER\\Desktop\\app\\as4t.py')
print(a)

C:\Users\USER\Desktop\app>as4t.py 1 2 3
['1', '2', '3']

How can i make my output[1, 2, 3]?


RE: converting string object inside a list into an intiger - Larz60+ - Mar-29-2020

listname[index] = int(listname[index])


RE: converting string object inside a list into an intiger - buran - Mar-29-2020

@bwdu, Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.

also, don't start new threads unnecessarily


RE: converting string object inside a list into an intiger - buran - Mar-31-2020

@bwdu, I strongly advise you to think carefully before posting any further without following Forum Rules or risk permanent ban. Giving negative rep to Moderator for advising you to follow rules is really stupid and childish.