Python 如何修复无效语法
在标题为#标题类型和大小的部分中,我想打印每个瓷砖的价格,但我无法分割数字。我该怎么解决这个问题?谢谢Python 如何修复无效语法,python,Python,在标题为#标题类型和大小的部分中,我想打印每个瓷砖的价格,但我无法分割数字。我该怎么解决这个问题?谢谢 print("Welcome to Terry Cotta's Tiling Company!") #Dimenstion of area to be tiled areaLength = int(input('Input length of area to be tiled in metres: ')) if areaLength <= 0: print('Area cann
print("Welcome to Terry Cotta's Tiling Company!")
#Dimenstion of area to be tiled
areaLength = int(input('Input length of area to be tiled in metres: '))
if areaLength <= 0:
print('Area cannot be lower than 0')
areaLength = int(input('Input length of area to be tiled in metres: '))
areaWidth = int(input('Input width of area to be tiled: '))
if areaWidth <= 0:
print('Area cannot be lower than 0')
areaWidth = int(input('Input length of area to be tiled in metres: '))
areaArea = areaLength*areaWidth
#Tile type and size
tiles = {'ceramic': '3', 'granite': '5', 'marble': '10'}
for x in tiles:
print(x.title() + " - Small: $" + int(tiles[x])/2 + " Medium: $" + tiles[x] + " Large: $" + int(tiles[x])*(2)
tileType = input("What type of tile would you like? Ceramic, granite or marble?: ")
tileType = tileType.lower()
while tileSuitable != 'yes':
if tileType not in tiles:
print('We do not provide that type of tile. Please enter again.')
tileType = input("What type of tile would you like? Ceramic, granite or marble?: ")
if tileType in tiles:
tileSize = input('What size tile would you like? Small, medium or large: ')
# else:
# print(tileType.title() + ' costs $' + tiles[tileType])
# confirmTileType = input('Is this your desired material? ')
# confirmTileType = confirmTileType.lower()
# if confirmTileType == 'no':
# tileType = input("What type of tile would you like? Ceramic, granite or marble. Type 'cost' for cost of materials: ")
print(“欢迎来到Terry Cotta的瓷砖公司!”)
#待平铺区域的尺寸
areaLength=int(输入('待平铺区域的输入长度,单位为米:'))
如果areaLength是因为您没有关闭打印功能
是:
print(x.title() + " - Small: $" + int(tiles[x])/2 + " Medium: $" + tiles[x] + " Large: $" + int(tiles[x])*(2)
print(x.title() + " - Small: $" + int(tiles[x])/2 + " Medium: $" + tiles[x] + " Large: $" + int(tiles[x])*(2))
print("Welcome to Terry Cotta's Tiling Company!")
areaLength = int(input('Input length of area to be tiled in metres: '))
#You could loop until you get correct value
while areaLength <= 0:
print('Area cannot be lower than 0')
areaLength = int(input('Input length of area to be tiled in metres: '))
areaWidth = int(input('Input width of area to be tiled: '))
#Same here loop until you get the correct value
while areaWidth <= 0:
print('Area cannot be lower than 0')
areaWidth = int(input('Input length of area to be tiled in metres: '))
areaArea = areaLength*areaWidth
tiles = {'ceramic': '3', 'granite': '5', 'marble': '10'}
for x in tiles:
print(x.title() + " - Small: $" + str(int(tiles[x])/2) + " Medium: $" + tiles[x] + " Large: $" + str(int(tiles[x])*(2)))
tileType = input("What type of tile would you like? Ceramic, granite or marble?: ")
tileType = tileType.lower()
#You had undeclared variable here so changed it
#And I really don't know what you were trying to do here
while tileType != 'yes':
if tileType not in tiles:
print('We do not provide that type of tile. Please enter again.')
tileType = input("What type of tile would you like? Ceramic, granite or marble?: ")
if tileType in tiles:
tileSize = input('What size tile would you like? Small, medium or large: ')
应该是:
print(x.title() + " - Small: $" + int(tiles[x])/2 + " Medium: $" + tiles[x] + " Large: $" + int(tiles[x])*(2)
print(x.title() + " - Small: $" + int(tiles[x])/2 + " Medium: $" + tiles[x] + " Large: $" + int(tiles[x])*(2))
print("Welcome to Terry Cotta's Tiling Company!")
areaLength = int(input('Input length of area to be tiled in metres: '))
#You could loop until you get correct value
while areaLength <= 0:
print('Area cannot be lower than 0')
areaLength = int(input('Input length of area to be tiled in metres: '))
areaWidth = int(input('Input width of area to be tiled: '))
#Same here loop until you get the correct value
while areaWidth <= 0:
print('Area cannot be lower than 0')
areaWidth = int(input('Input length of area to be tiled in metres: '))
areaArea = areaLength*areaWidth
tiles = {'ceramic': '3', 'granite': '5', 'marble': '10'}
for x in tiles:
print(x.title() + " - Small: $" + str(int(tiles[x])/2) + " Medium: $" + tiles[x] + " Large: $" + str(int(tiles[x])*(2)))
tileType = input("What type of tile would you like? Ceramic, granite or marble?: ")
tileType = tileType.lower()
#You had undeclared variable here so changed it
#And I really don't know what you were trying to do here
while tileType != 'yes':
if tileType not in tiles:
print('We do not provide that type of tile. Please enter again.')
tileType = input("What type of tile would you like? Ceramic, granite or marble?: ")
if tileType in tiles:
tileSize = input('What size tile would you like? Small, medium or large: ')
对代码的小更改:
print(x.title() + " - Small: $" + int(tiles[x])/2 + " Medium: $" + tiles[x] + " Large: $" + int(tiles[x])*(2)
print(x.title() + " - Small: $" + int(tiles[x])/2 + " Medium: $" + tiles[x] + " Large: $" + int(tiles[x])*(2))
print("Welcome to Terry Cotta's Tiling Company!")
areaLength = int(input('Input length of area to be tiled in metres: '))
#You could loop until you get correct value
while areaLength <= 0:
print('Area cannot be lower than 0')
areaLength = int(input('Input length of area to be tiled in metres: '))
areaWidth = int(input('Input width of area to be tiled: '))
#Same here loop until you get the correct value
while areaWidth <= 0:
print('Area cannot be lower than 0')
areaWidth = int(input('Input length of area to be tiled in metres: '))
areaArea = areaLength*areaWidth
tiles = {'ceramic': '3', 'granite': '5', 'marble': '10'}
for x in tiles:
print(x.title() + " - Small: $" + str(int(tiles[x])/2) + " Medium: $" + tiles[x] + " Large: $" + str(int(tiles[x])*(2)))
tileType = input("What type of tile would you like? Ceramic, granite or marble?: ")
tileType = tileType.lower()
#You had undeclared variable here so changed it
#And I really don't know what you were trying to do here
while tileType != 'yes':
if tileType not in tiles:
print('We do not provide that type of tile. Please enter again.')
tileType = input("What type of tile would you like? Ceramic, granite or marble?: ")
if tileType in tiles:
tileSize = input('What size tile would you like? Small, medium or large: ')
print(“欢迎来到Terry Cotta的瓷砖公司!”)
areaLength=int(输入('待平铺区域的输入长度,单位为米:'))
#可以循环,直到得到正确的值
当areaLength复制并粘贴你的错误在这里。它只是说“无效语法”只要试着注释一些代码,你可能会找到错误的正确位置。简单地把你所有的代码粘贴到这里,然后让其他人检查一下是不好的,但是现在我怎么才能让它打印出所有的价格呢?我试过转换成整数之类的东西,但是没有worked@dbab请参见编辑更改为您的understanding@VigneshKalai非常感谢你的帮助@VigneshKalai Yep,标记为正确:)