小编Geo*_*ata的帖子

Python /字符串/辅音

我正试图解决这个问题,如何在句子中表达辅音.我刚刚使用的代码似乎没有完成这项工作:

vowels = ("aeiou")
count = 0
for x in text:
    if not x in vowels:
        count += 1
Run Code Online (Sandbox Code Playgroud)

在示例"hello world"中作为输入,我收到8个辅音.提前谢谢了.

python

2
推荐指数
1
解决办法
1万
查看次数

如何确保第一个随机值总是大于第二个?

码:

def Division():

    print "************************\n""********DIVISION********\n""************************"
    counter = 0
    import random
    x = random.randint(1,10)
    y = random.randint(1,10)
    answer = x/y
    print "What will be the result of " + str(x) + '/' + str(y) + " ?"
    print "\n"
    userAnswer = input ("Enter result: ")
    if userAnswer == answer:
        print ("Well done!")
        print "\n"
        userInput = raw_input ("Do you want to continue? \n Enter 'y' for yes or 'n' for no.")
        if userInput == "y":
            print "\n"
            Division()
        else:
            print "\n" …
Run Code Online (Sandbox Code Playgroud)

python

0
推荐指数
1
解决办法
126
查看次数

标签 统计

python ×2