Copying rasters to new geodatabase question

I am new to ArcPy and python. I am currently working on exercise 9.2 in Python Scripting for ArcGIS by Paul Zanbrtgen. The question is pretty simple and is asking to write a scrip that copies rasters into a new Geodatabase. I run print statements and everything is fine until I reach the arcpy.CopyRaster_management(raster, outraster). I am wondering if there is something wrong with the formatting of the file names. It throws a 999999 error. How long did it take you to really become comfortable in the Arcpy environment and with python in general. My goal is to build python based geoprocessing tools one day.

Good for you picking up python and arcpy. I took a class in grad school in python and arcpy and have used that same book myself before. I didn't get too comfortable with it though til I found real applications for its use where I work and its been quite the timesaver for me.

Now to your questions.

You are getting the base name property of the raster but not an extension(file type). Your output from Copy Raster will need a file type or it will default to a GRID file which has a 13 character limit and limits the character types that can be in the name. This is likely causing your issue.

Also when joining paths and file names, I recommend using the os module and os.path.join to combine your path and name instead of concatenation.

IT was so simple, Thanks for your help!. I just changed it to CreateFileGDB management. Thanks for all your help! Hopefully as I see more python, ill pick up on this more. I am working backwards through these exercises to I can see how python fits together.