鱼C论坛

 找回密码
 立即注册
查看: 712|回复: 4

[已解决]帮手补充代码

[复制链接]
发表于 2020-5-30 02:03:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
import random 
name=["あ","い","う","え","お",
      "か","き","く","け","こ",
      "さ","し","す","せ","そ",
      "た","ち","つ","て","と",
      "な","に","ぬ","ね","の",
      "は","ひ","ふ","へ","ほ",
      "ま","み","む","め","も",
      "や","ゆ","よ",
      "ら","り","る","れ","ろ",
      "わ","を",]

print(random.choice(name))
while input():
        print(random.choice(name))

写了个代码学习五十音

如何添加一个对错分支来判断input()的
内容是否=随机出来的字符串
if = 就循环
if != 就print('wrong') 重新input('重新输入')

啊我不知道我能不能表达清楚,小小白一枚
最佳答案
2020-5-30 02:38:31
我不知道 你想要的是不是这样结果,不过可以参考下
import random
name=["あ","い","う","え","お",
      "か","き","く","け","こ",
      "さ","し","す","せ","そ",
      "た","ち","つ","て","と",
      "な","に","ぬ","ね","の",
      "は","ひ","ふ","へ","ほ",
      "ま","み","む","め","も",
      "や","ゆ","よ",
      "ら","り","る","れ","ろ",
      "わ","を",]

print(random.choice(name))
while True:
    a = (random.choice(name))
    print(a)
    shuru = input()
   
    print(a)
    if shuru == a:
        pass
    else:
        print('错误')
        while True:
            shuru = input()
            if shuru == a:
                break
            else:
                print('错误')
        
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-5-30 02:38:31 | 显示全部楼层    本楼为最佳答案   
我不知道 你想要的是不是这样结果,不过可以参考下
import random
name=["あ","い","う","え","お",
      "か","き","く","け","こ",
      "さ","し","す","せ","そ",
      "た","ち","つ","て","と",
      "な","に","ぬ","ね","の",
      "は","ひ","ふ","へ","ほ",
      "ま","み","む","め","も",
      "や","ゆ","よ",
      "ら","り","る","れ","ろ",
      "わ","を",]

print(random.choice(name))
while True:
    a = (random.choice(name))
    print(a)
    shuru = input()
   
    print(a)
    if shuru == a:
        pass
    else:
        print('错误')
        while True:
            shuru = input()
            if shuru == a:
                break
            else:
                print('错误')
        
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-5-30 03:23:09 | 显示全部楼层
均昊山 发表于 2020-5-30 02:38
我不知道 你想要的是不是这样结果,不过可以参考下
import random
name=["あ","い","う","え","お",

对对,就多了两行print
感谢!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-5-30 08:40:02 | 显示全部楼层
Ychan 发表于 2020-5-30 03:23
对对,就多了两行print
感谢!

问题如果已经解决,就给2楼设置最佳结账
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-5-30 10:12:12 | 显示全部楼层
Twilight6 发表于 2020-5-30 08:40
问题如果已经解决,就给2楼设置最佳结账

然鹅他并没有设置
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-1-21 00:51

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表