-4

I need this list deneme=['/n 1991','/n 1993','/n 2020']

pure_deneme=["1991","1993","2020"] like this list and all values must be integer. Thanks.

baduker
  • 19,152
  • 9
  • 33
  • 56

1 Answers1

1

Thats easy with list comprehensions:
if by '/n' you mean '\n' then you can simply do:

new_list = [int(element) for element in old_list]

if it is indeed '/n' you may have to do:

new_list = [int(element.replace('/n ', '')) for element in old_list]

This difference is because int() already knows how to ignore spaces and new lines ('\n'), but if there are other characters in there you will need to remove them with .replace('whatever', '')

motrix
  • 348
  • 1
  • 9