我试着这样做:你输入这样一个词:Happy,然后程序返回这样的东西:yppaH或appHy。你知道吗
问题是我只得到一个字母:y或H,等等。。你知道吗
import random
def myfunction():
"""change letter's position"""
words = input("writte one word of your choice? : ")
words = random.choice(words)
print('E-G says : '+ words)
Tags:
你必须使用
sample
,而不是choice
。你知道吗如果要打印反向单词,这将是最快的方法:
在转换列表中的字符串时使用
random.shuffle
(就地工作)然后使用
str.join
转换回字符串输出:
相关问题 更多 >
编程相关推荐