How do I add an int to the end of a sting Python?

you can add an int to the end of a string with the help of type conversion.

In this example, we simply convert the int data type to string data type using type conversion and adding it to the appropriate position.

Steps:

step1: take a string data type.

step2: take an int data type.

step3: convert the int into the string using type conversion.

step 4: add the string and int and assign to a variable.

step5: print the variable.

Example:

string = "python"

int = 446

res = string + str(int)

print("The string after adding number is : " + str(res))

By using the %d operator:

string = "python"

int = 446

res = (string + "%d")%int

print("The string after adding number is : " + str(res))

Output:

python446

Comments

Popular posts from this blog

proassignment help backlink data index 41

programming shark backink data index 31

Programming shark backlink data index 67