问题描述
我发现了使 this 更长的代码(不是i ...放入 this 的更多简写代码(注意n变量): 我的问题是,为什么不是“ size_t n = strlen(string1)”?为什么不给n数据类型? 谢谢!elif user_input == "a":
while True:
try:
add_item = input("What item would you like to add? ").lower()
if not re.match("^[a-z,A-Z]*$",add_item):
print("ERROR: Only letters A-Z are allowed!")
continue
elif len(add_item) < 1 or len(add_item) > 20:
print("Item name is too long,only a maximum of 20 characters are allowed!")
continue
else:
item_amount = int(input("How many of these would you like to add? "))
shopping_list[add_item] = item_amount
print(f"{item_amount}x {add_item.title()} added to the shopping list.\n")
while True:
try:
add_more = input("Would you like to add more items? (y/n): ").lower()
if add_more == "y":
break
elif add_more == "n":
break
except TypeError:
print("ERROR: Expected y or n in return! Try again!.\n")
break
except ValueError:
print("\nERROR: Amount must be an integer! Try adding an item again!\n")
for (int i = 0; i < strlen(string1); i++)
{
printf("%c",string1[i]);
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)