So I'm learning python and I've tried to use this code to make an image duplicator for convenience so that I can replicate this image 5 (or any other number) times at once, but I keep getting this problem.
import shutil
src = r'D:\src\C:\Users\Gamal\Pictures\Picture21.jpg'
ext = r'.jpg'
#Change the 5 to what number you want to duplicate
for i in range(5):
shutil.copy(src, f'{src (i) ext}')```
CodePudding user response:
It means you can't use
with src
(a string) and i
(an integer).
Use f-string interpolation as is and don't try to use
to "sum up" integers with strings:
for i in range(5):
shutil.copy(src, f'{src}{i}{ext}')
CodePudding user response:
i is an integer but src is a string you can't use for two different types.