小甲鱼的视频听到第6个,请教如下如何,怎么能够将输出搞成横的。小白一名
"""用Pyhon设计第一个游戏"""x=3
while x > 0:
temp = input("不妨猜一下美女现在心里想的是哪个数字:")
guess = int(temp)
if guess == 8:
print("你是美女心里的蛔虫么?!")
print("猜中了也没奖励!")
break
else:
if guess > 8:
print("大了")
x = x - 1
print("你")
print("还")
print("有")
print( x )
print("次")
print("机")
print("会")
else:
print("小了")
x = x - 1
print("你")
print("还")
print("有")
print( x )
print("次")
print("机")
print("会")
print("不玩了") 本帖最后由 Judie 于 2020-4-18 11:46 编辑
print("你还有", x, "次机会") print("大了",end='') 就可以不换行,但是2楼回答最直接 print("你",end="")
print("还",end="")
print("有",end="")
print( x,end="" )
print("次",end="")
p ...
end 是函数print() 的一个参数,用来指定打印结束时末尾的符号,默认是回车 -> 默认是换行 Judie 发表于 2020-4-19 12:17
print("你",end="")
print("还",end="")
print("有",end="")
谢谢,看来PRINT函数有多个参数。 Judie 发表于 2020-4-19 00:37
多谢,学习了 emmmm,你不觉得你一个字一个字的打印,好麻烦的
"""用Pyhon设计第一个游戏"""
x=3
while x > 0:
temp = int(input("不妨猜一下美女现在心里想的是哪个数字:"))
if temp == 8:
print("你是美女心里的蛔虫么?!")
print("猜中了也没奖励!")
break
else:
if temp > 8:
print("大了")
x = x - 1
print("你还有%d次机会"%x)#%d是占位
else:
print("小了")
x = x - 1
print("你还有%d次机会"%x)#%d是占位
print("不玩了")
页:
[1]