[英]i got an error while printing a particular symbol definite times (python)
sym = input("Enter the symbol : ")
name = input("Enter the number of times : ")
print(sym* name)
我收到一個錯誤:
TypeError:不能將序列乘以“str”類型的非整數
如果您希望 sym 打印一定次數,那么您應該將第二個變量顯式類型轉換為 integer。
sym = input("Enter the symbol : ")
name = int(input("Enter the number of times : "))
print(sym* name)
sym = input("Enter the symbol : ")
name = int(input("Enter the number of times : "))
print(str(sym) * int(name))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.