Here is the background information: I have a .txt file with some numbers on it that are all separated by commas. Then, using Python code, I opened it and read it. After that, I made a list out of all of the numbers that were on the file. When I made a list, the numbers were all strings (example: '9', '8', etc.), so I used some Python code to convert the values of the list into integers. Now, I am trying to create some code so that I can convert all of the integers in the list to hexadecimal. The reason I want to create a piece of code instead of doing it manually is that there are around 20 numbers (in decimal format) and I want to convert them all into hexadecimal using some piece of Python code. Here is my code so far (until the point of converting the list to integers). Please help! I have tried to search so much on Google but could not find anything specific to this.
Code:
my_file = open(r'C:\Users\USER\Downloads\List of Numbers File.txt', encoding='utf-8-sig')
content = my_file.read()
print(content)
content_list = content.split(",")
my_file.close()
print(content_list)
for i in range(0, len(content_list)):
content_list[i] = int(content_list[i])
print(str(content_list))
content_list[i] = hex(int(content_list[i]))
?