How to create a string from two given strings and swap the first two characters of each string in Python

1 Answer

0 votes
def swap_nad_merge(s1, s2):
  new_s1 = s2[:2] + s1[2:]
  new_s2 = s1[:2] + s2[2:]

  return new_s1 + ' ' + new_s2
  
  
print(swap_nad_merge('python', 'java'))


 
 
'''
run:
 
jathon pyva
 
'''

 



answered Aug 30, 2021 by avibootz

Related questions

...