为新手帮助word unscrambler代码? [英] Help with word unscrambler code for newbie?

查看:47
本文介绍了为新手帮助word unscrambler代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Python新手,需要一些帮助。我试图一次拿出10个混乱的单词并让程序解读它们然后将它们打印出来,如:word1,word2,word3等。

到目前为止,代码将解读的不仅仅是一次一个单词,但如果单词中有多个相同的字母,它会多次打印答案,并将它们打印在一列中。例子是inwdwo和garnama(窗口字谜)。会像这样打印出来:

窗口

窗口

anagram

anagram

anagram。

我读到一套可以帮助这个,但我不知道该放在哪里或如何获得%s,%s,%s类型的打印输出。任何帮助?

Hi, I''m new to Python and need some help with this program. I''m trying to take 10 jumbled words at a time and have the program unscramble them and then print them out like: word1,word2,word3, etc.
So far the code will unscramble more than one word at once but it will print the answer several times if there is more than 1 of the same letter in the word and it will print them in a column. Example is inwdwo and garnama (window anagram). It will print them like this:
window
window
anagram
anagram
anagram.
I read that a set can help this but I''m not sure where to put that or how to get the %s,%s,%s type of print out. Any help?

展开 | 选择 | Wrap | 行号

推荐答案

你非常接近。这似乎有效:
You were very close. This seems to work:
展开 | 选择 | Wrap | 行号


如果您使用的是Python 2.4及更高版本,这将消除列表中的重复项:
If you are in Python 2.4 and above, this will eliminate duplicates from the list:
展开 | 选择 | Wrap | 行号


谢谢Bvdet的回复!我正在使用2.5。我尝试了你的建议,这部分适用于重复单词部分:
Thank you, Bvdet for the replies! I''m using 2.5. I tried your suggestions and this part worked for the repeating words part:
展开 | 选择 | Wrap | 行号


这篇关于为新手帮助word unscrambler代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆