小编Tha*_*Guy的帖子

协助/审查我的python 3虚拟巴士的座位问题

当前脚本为站立状态

totSeat = 100

print("Seats Remaining", totSeat, end = " ")
gSeat = int(input("How many in your group?"))
while gSeat != 100:
    totSeat -= gSeat
    if gSeat <= 100:
        print("Booked, Thank You")
        print("Seats Remaining", totSeat, end=" ")
        gSeat = int(input("How many in your group?"))
        if totSeat <= 1:
            print("Booked, Thank You\nSOLD OUT")
            break
    if gSeat < totSeat:
        print("Sorry, not enough seats left.")
        gSeat = int(input("How many in your group?"))
Run Code Online (Sandbox Code Playgroud)

基本上

如果“ totSeat”(总席位)为0,我需要打破并说售罄。如果“ gSeat”(宾客座位)在“ totSeat”之上(包括使用输入101+的情况),我需要显示“对不起,座位不足”。

就像站立一样,它有点像这样,但是变得有些笨拙,甚至在跌破之前陷入可用的-1个座位。我对python非常陌生,因为它对真正粗糙的脚本表示歉意

python python-3.x

4
推荐指数
1
解决办法
54
查看次数

标签 统计

python ×1

python-3.x ×1