What's the difference between str( ) and ""?

https://www.codecademy.com/courses/learn-python-3/articles/advanced-python-code-challenges-functions

For exercise #3,

Write a function named introduction() that has two parameters named first_name and last_name .

The function should return the last_name , followed by a comma, a space, first_name another space, and finally last_name .

I was confused when to use str( ) and " ". Also, can str ( ) include text and number?

Well, you would use str() when you want to convert something with a different type into a string. For example type(6) would give you like class int or something like that. So if you did str(6), it would change 6’s type into a str, an alternative to having to type β€œ6”. " " Just refers to an empty string with a space in it.
Like let’s say you had code like this:

print('Hello')
print(6)

And the output would look like this:

Hello
6

Now what if you wanted to seperate them by a space?

print('Hello')
print(" ") #well in this particular situation the space isn't really necessary, but you get the point
print(6)

Now output is

Hello

6
3 Likes

Using quotation marks, or apostrophies designates a string when it is written in the code:

a = "This is a string"

str() is a function designed to get the string version of a non string object. It does not modify the variable it is used on, and will instead return a copy of it that can be used as a string:

number = 5
string = str(number) #str() will not modify the variable it is used on
                     #Instead it returns a new value

number += 6 #Because number was not modified you can still perform math
string /= 5 #However this throws an error since you can't divide 
            #a string in this way
3 Likes