Search code examples
pythonexcelstringintegerxlsxwriter

How do I concatenate string and an integer?


act = input("Enter name of the activity")
cellone = int(input("Enter the order number of activity"))
cell1 = "A" + cellone
worksheet.write(cell1, act)
  

I'm trying to concatenate A and cellone but I'm getting some error saying that I can't concatenate string and an integer, is there a way to do this?


Solution

  • You can change int to a string representation using this:

    cell1="A"+str(cellone)
    

    Alternatively, f-string formatting will also work:

    cell1=f"A{cellone}"