Monday, October 17, 2022

[FIXED] How do I concatenate string and an integer?

Issue

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}"


Answered By - SultanOrazbayev
Answer Checked By - David Marino (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.