To copy string in python, you have to ask from user to enter a string and then copy that string into another string variable and finally print the value of that string variable as shown in the program given here.
Following python program ask from user to enter a string to copy that string:
# Python Program - Copy String print("Enter 'x' for exit."); string = input("Enter any string to copy: "); if string == 'x': exit(); else: print("Copying string 1 (string) into string 2 (cstring)..."); cstring = string; print("\nString 2 after successfully copied =",cstring); print("\nString 1 =",string,"\nString 2 =",cstring);
Here is the sample run of the above Python program illustrating how to copy string:
Now enter any string say codescracker and then press enter key to copy the given string into another string variable and then print it out the value of that variable where the given string is copied as shown below:
Same program on python shell:
Program Video with Compile and Run
You may also like to learn or practice the same program in other popular programming languages: