当前脚本为站立状态
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非常陌生,因为它对真正粗糙的脚本表示歉意
我有一个字符串值作为abc:language-letters-alphs/EnglishData:7844val:. 我想提取部分language-letters-alphs/EnglishData,即 first:和 second之间的值:。有没有办法在不将每个子字符串存储在不同的变量上的情况下做到这一点?我想用 ES6 的方式来做。