如何在for循环中使用函数参数中的数字赋值

时间:2022-12-27 09:11:27

i am having trouble in assigning the number 'numTiles' to a for Loop in my code. It says that "An attempt was made to call a function with a parameter of an invalid type." How do i assign the number of times my for loop to run from the number i assigned when calling the function?

我在代码中将数字'numTiles'分配给for循环时遇到了麻烦。它说“尝试使用无效类型的参数调用函数。”如何从调用函数时指定的数字中指定运行循环的次数?

code:

def createSquareTile(numTiles, prefix):
  current = 1
  numTilesI = int(numTiles)
  for i in numTilesI:
    if current == 1:
      size = requestNumber("Please input a positive number")
      sizeI = int(size)

How do i use the number i assigned in numTiles when calling the function in my for loop? Thanks in advance!

在my循环中调用函数时,如何使用numTiles中指定的数字?提前致谢!

1 个解决方案

#1


0  

I've found the solution,

我找到了解决方案,

for i in range(numTilesI): 

#1


0  

I've found the solution,

我找到了解决方案,

for i in range(numTilesI):