-4
print(row["first"], row["last"], ",", "born", row["birth"])

Output:

Ronald Bilius Weasley , born 1980

I want to remove space after Weasley.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135

2 Answers2

1

The , in print will automatically show you a whitespace after it, so you can prevent this like this:

print(row["first"], row["last"] + ",", "born", row["birth"])

Alternatively you could also do this:

print("{} {}, born {}".format(row["first"], row["last"], row["birth"]))
Andreas
  • 8,694
  • 3
  • 14
  • 38
0

You can use sep option like this. sep is used to denote how you want to separate. By default, python uses space for comma. you can change that by resetting the value of sep to ''

print(row["first"], " ",row["last"], ", born ", row["birth"], sep = '')

Output:

Ronald Bilius Weasley, born 1980

There are many ways to solve your code. The above one is one of the ways. Here is a link to look at a few options.

What are the difference between sep and end in print function?

You can try to use str.join() or .format() options or simple + to concatenate strings.

To learn more about format printing, see this link. https://pyformat.info/

Joe Ferndz
  • 8,417
  • 2
  • 13
  • 33