Python Forum
problem in using int() with a list of strings
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem in using int() with a list of strings
#1
hi
i am a beginner in python, so this problem that i encountered, maybe is silly.
i wrote in idle:

y=['l', '2', '3', '5', '8', '6', '9']
when i write int(y[0]) then i have an error as:
Traceback (most recent call last):
File "<pyshell#87>", line 1, in <module>
int(y[0])
ValueError: invalid literal for int() with base 10: 'l'

but when i write int(y[1]) or int(y[2]) , the correct values are displayed and there is no error. i searched net for this but i can not true thing.
thanks
Reply


Messages In This Thread
problem in using int() with a list of strings - by akbarza - Jul-19-2023, 01:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read module/class from list of strings? popular_dog 1 558 Oct-04-2023, 03:08 PM
Last Post: deanhystad
  Trying to understand strings and lists of strings Konstantin23 2 896 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Delete strings from a list to create a new only number list Dvdscot 8 1,725 May-01-2023, 09:06 PM
Last Post: deanhystad
  Help with Logical error processing List of strings dmc8300 3 1,176 Nov-27-2022, 04:10 PM
Last Post: Larz60+
  Problem with "Number List" problem on HackerRank Pnerd 5 2,220 Apr-12-2022, 12:25 AM
Last Post: Pnerd
  Splitting strings in list of strings jesse68 3 1,889 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  How to find the first and last of one of several characters in a list of strings? tadsss 2 2,265 Jun-02-2020, 05:23 PM
Last Post: bowlofred
  Problem with replacing strings donnertrud 3 2,216 May-22-2020, 04:06 PM
Last Post: donnertrud
  Iterating through a list of strings Ash_Ren 1 2,149 Nov-22-2019, 08:30 PM
Last Post: buran
  How do I delete symbols in a list of strings? Than999 1 2,344 Nov-16-2019, 09:37 PM
Last Post: ibreeden

Forum Jump:

User Panel Messages

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