字符串和变量不会连接在同一行

String and variables won't concatenate on same line

我无法使用以下代码在同一行上打印序列号和单词定义。任何建议将不胜感激。我已经阅读了之前关于此问题的问答,但没有运气。

from bs4 import BeautifulSoup

import requests

loops = ""

while loops == "":

    url = "http://dictionary.reference.com/browse/"

    c = 1
    word = input("Enter word (0 to quit): ")
    if word == "0":
        break
    data = requests.get(url + word)

    soup = BeautifulSoup(data.text, "html.parser")

    data1 = soup.find_all("div",{"class":"def-content"})

    print("The meaning/s of " + word + " is/are:")

    for i in data1:
        if i.string != None:
            print(c, i.string)  # Trying to print serial number and definition on same line
            c = c + 1

试试这个:

        print(str(c)+ " " + i.string.strip('\n'))