Computer Science, asked by Harshchacharkar7168, 1 year ago

How to assign value int avlue to string in python?

Answers

Answered by Vk73829301
0
I'm working in Python and I have a list of integers: [1, 2, 1, 3, 2, 2, 1, 3].

I want to assign each integer a string as if it were a variable: ['red', 'orange', 'red', 'yellow', 'orange', 'orange', 'red', 'yellow'].

How would I go about doing this?

In that example, 1 corresponds to 'red', 2corresponds to 'orange', and 3 corresponds to 'yellow'.

Similar questions