0

I have a list of data that comes in the form of lists with numbers in them. as an intermediate step to making them all integers, I need to remove all the non-number parts within the element.

['jeff','69','420','80085\n']

how do I check to see if \n is in an element and how do I remove it if it is?

['jeff','69','420','80085']

Is the wanted output. I literally don't know how to start, I can turn the numbers into integers using loops and intermediate variable but trying to identify things within them is not something i know how to do.

Alice D
  • 33
  • 5

1 Answers1

0
>>> input = ['jeff','69','420','80085\n']
>>> output = [x.replace('\n','') for x in input]
>>> output
['jeff', '69', '420', '80085']
abhinsit
  • 3,214
  • 4
  • 21
  • 26