Very noob question


#1



Thank you for taking time to help me!

https://www.codecademy.com/en/courses/python-beginner-sRXwR/4/1?curriculum_id=4f89dab3d788890003000096


Doesn't make a string


It should make pirate a string


Replace this line with your code. 
# Write your code below, starting on line
my_string=str(pirate)
print len(my_string)
print my_string.upper()

I know I could use quotation marks instead of str(), but I want to understand what str() is used for exactly since it doesn't seem to create a string in this problem.

I am also stuck on this

https://www.codecademy.com/courses/python-beginner-en-zFPOx/0/4?curriculum_id=4f89dab3d788890003000096#

from datetime import datetime
now = datetime.now()
-="/"
print '%s-%s-%s' % (now.day, now.month, now.year)

It seems I can't make / a string/variable of -

I thought adding a \ before hand would fix it, but it doesn't. What is the correct script for this problem?


#2

To address the first portion of your question, the str() method is a form of typecasting. It allows you to convert other data types into a String. When you did str(pirate), Python considers pirate a variable that it cannot find. You should only use str() when dealing with other data types and create strings through quotation marks.

For the second part, all the program is asking you to do is replace the '-' with a '/'. Just simply delete the dash(-) and replace it with the forward slash(/). Hope this helps.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.