-1

I am making a program to estimate tile jobs easier. I have the user input the number of different tiles there are into a range list (ex: Tile = [1,2,3,4,5])

Now I would like to convert every one of those numbers into their own list (ex: 1 becomes TileA, 2 becomes TileB, etc).

nbtile = input("How many different types of tile is there?")

tile = list(range(1,(int(nbtile)+1)))
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • 1
    You don't want to do that, really, as it'll make the rest of your code *much harder to write*. – Martijn Pieters Mar 30 '19 at 17:19
  • Must the new lists have names like TileA, TileB... or do you just want a number of new lists according to the number of elements in Tile? – Code Pope Mar 30 '19 at 17:20
  • I would like it to have a name like that because in my code I have rooms, tile and cement, all in multiple. My goal in here is to associate a numercal value to my new item ex: TileA=24 – Matthew Mannella Mar 30 '19 at 17:23
  • If any of the answers solved your question, it's good practice to upvote and accept. The latter also grants you a small rep bonus :) – Alec Mar 30 '19 at 17:31

1 Answers1

0

You can use a simple generator expression:

nbtile = input("How many different types of tile is there?")

tile = list(range(1,(int(nbtile)+1)))

tiles, tiledict = [[x] for x in tile], {}

for x in range(len(tiles)):
    tiledict[f'TILE{x+1}'] = tiles[x]

print(tiledict)
Alec
  • 8,529
  • 8
  • 37
  • 63