First of all, this is not related to this course. I was trying to find somewhere to post this question but I couldn’t find an area that wasn’t course related, so if this is not allowed just tell me.
I want to create a simple code that takes a number (ex: 345122) and makes even numbers 1 and odd numbers 2, and then prints the number (212211).
This is what I was thinking:
number = input('Write a number ') for i in range(len(number)): if int(number[i])%2 == 0: number[i] = 1 else: number[i] = 2 print(number)
The problem in this is that you can’t change an index’s content in a string. How else can I do this? Should I make it a list and then add them all together? How do I do that?