day4~day6

list 部分

string = “abcde”
strList = list(string) #將字串轉為list
#[a,b,c,d,e]
#list to string
finalPassword = “”.join(strList ) #用空字串提示要join list後的型態

1 Like
print("Welcome to Python Pizza Deliveries!")
size = input("What size pizza do you want? S, M, or L ")
add_pepperoni = input("Do you want pepperoni? Y or N ")
extra_cheese = input("Do you want extra cheese? Y or N ")

total = 0
if size == "L":
  total += 25
  if add_pepperoni == "Y":
    total += 3
elif size == "M":
  total += 20
  if add_pepperoni == "Y":
    total += 3
elif size == "S":
  total += 15
  if add_pepperoni == "Y":
    total += 2

if extra_cheese == "Y":
  total += 1

print(f"Your final bill is ${total}.")
1 Like

image

1 Like

image

1 Like

請問是 程式碼輸入 不順是嗎?所以改用圖檔?
這篇有提及,也許有幫助。請參考,謝謝!

passwordList = list(password) #將字串轉為 list
    print (passwordList)
random.shuffle(passwordList) # shuffle 不能處理 string 只能用 list
#list to string
finalPassword = "".join(passwordList) #用空字串提示要 join list  後的型態
    print (finalPassword)
1 Like