To get your current code to work, you should use the or
operator in your condition instead of and
, and use a conditional operator to default your list values to a space if the index is not less than the length of the list:
s1 = 'hello'
s2 = 'paul'
i = 0
while i < len(s1) or i < len(s2):
print(s1[i] if i < len(s1) else ' ', s2[i] if i < len(s2) else ' ')
i += 1