关于#Python#的问题,如何解决?

三是求单词的长度并排序,四是求曼哈顿距离,尽量简易易懂,且第四题尽量使用for循环,大概就是这样了

img

//3.输入多个以逗号分隔的单词,按字母顺序排序
words = input().split(',')
words.sort()
print(words)

//4.
p1 = list(eval(input('enter the coordinates of the first point (separated by commas):')))
p2 = list(eval(input('enter the coordinates of the second point (separated by commas):')))
s = 0
for i in range(0,len(p1)):
    s = s + abs(p1[i]-p2[i])

print(s)

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632