Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 views
in Technique[技术] by (71.8m points)

python-3.x - 如何在每个打印结果旁边添加其他文本?(How do I add additional text next to each print result?)

Here is my code:

(这是我的代码:)

from functools import partial

def x_in_y(word, inner):
    return inner in word

wrong = ['mann','connaction','tee','rigt','putt']
sentence=['this mann is my son','the connaction is unstable','my tee is getting cold','put your hands down','rigt now','right behind my back']

for i in wrong:
    print(f"Wrong: {i}")
    filtered_names = filter(partial(x_in_y, inner=i), sentence)
    for name in filtered_names:
        print(name)

How could I add a correct word next to each labels?

(如何在每个标签旁边添加正确的单词?)

then it implies the correct word for each result.

(则表示每个结果正确的单词。)

Like this one:

(像这个:)

Wrong: mann "should be man"
this mann is my son
Wrong: connaction "should be connection"
the connaction is unstable
Wrong: tee "should be tea"
my tee is getting cold
Wrong: rigt "should be right"
rigt now
  ask by briiipo translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...