You could do something like this:
string = ''
for t in range(1,8):
if t % 2 == 0: # if t is even multiply t by 3 and add t to the string
string += str(t * 3) + ' '
else: # if t is odd simply add t to the string
string += str(t) + ' '
print(string)
Ouptut:
1 6 3 12 5 18 7
I added a space after each number simply makes the output easier to read. If you want you could remove the + ' '
in the code to get this output:
163125187
2
solved multiplying numbers in a string [closed]