Ask Your Question
4

How can I use syntax to print the equation "2 + 2 = 4" in the format of "5 + 5 = 10"?

asked 2021-08-06 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-06-14 16:00:00 +0000

devzero gravatar image

One way to do this would be to replace each digit with its double:

2 + 2 = 4

becomes

5 + 5 = 10

In Python, you could write:

print("2 + 2 = 4".replace("2", "5").replace("4", "10")) 

This will output:

5 + 5 = 10
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-08-06 11:00:00 +0000

Seen: 20 times

Last updated: Jun 14 '21