lpython icon indicating copy to clipboard operation
lpython copied to clipboard

Add space between multiple strings while printing

Open kmr-srbh opened this issue 1 year ago • 2 comments

fixes #2669

print("a", "b", "c", "d")

fruits: list[str] = ["apple", "guava", "mango"]
mango: str = fruits.pop()
print("I have got a", mango, "to eat!")
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
a b c d
I have got a mango to eat!

kmr-srbh avatar Apr 26 '24 12:04 kmr-srbh

@Shaikh-Ubaid could you please rerun the CI? The failing check is unrelated to the PR.

kmr-srbh avatar Apr 26 '24 13:04 kmr-srbh

The approach in this PR might break lfortran. lfortran needs to not print spaces when two consecutive print arguments are strings.

% cat examples/expr2.f90     
program expr2
implicit none

print *, "hi", "bye"
print *, 12, 23

end program
% gfortran examples/expr2.f90 
% ./a.out 
 hibye
          12          23
% lfortran examples/expr2.f90
hibye
12 23

ubaidsk avatar Apr 26 '24 18:04 ubaidsk