Python Forum
converting string object inside a list into an intiger
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
converting string object inside a list into an intiger
#1
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]?
Reply
#2
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]?
Reply
#3
listname[index] = int(listname[index])
Reply
#4
@bwdu, Please, use proper tags when post code, traceback, output, etc.
See BBcode help for more info.

also, don't start new threads unnecessarily
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
#5
@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.
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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Return a string or byte object from Enum class? Calab 5 1,859 May-14-2025, 05:21 PM
Last Post: snippsat
  Formatting DateTime string and and converting it from AM/PM to 24 hours tester_V 2 1,868 Jun-08-2024, 05:16 PM
Last Post: tester_V
  how to capitalize letter in list object Python iwonkawa 4 2,035 May-29-2024, 04:29 PM
Last Post: DeaD_EyE
  Possible to create an object inside another object that is visible outside that objec MeghansUncle2 17 9,873 May-25-2023, 02:08 PM
Last Post: MeghansUncle2
  How do I call sys.argv list inside a function, from the CLI? billykid999 3 2,836 May-02-2023, 08:40 AM
Last Post: Gribouillis
  add object and name in list 3lnyn0 4 2,970 Nov-24-2022, 07:33 PM
Last Post: buran
  bytearray object - why converting to ascii? Chepilo 2 6,691 Nov-21-2022, 07:25 PM
Last Post: Chepilo
  Converting '1a2b3c' string to Dictionary PythonNoobLvl1 6 4,269 May-13-2022, 03:44 PM
Last Post: deanhystad
  AttributeError: 'list' object has no attribute 'upper' Anldra12 4 9,089 Apr-27-2022, 09:27 AM
Last Post: Anldra12
  AttributeError: 'list' object has no attribute 'values' ilknurg 4 24,690 Jan-19-2022, 08:33 AM
Last Post: menator01

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.