1/16 exercise of python


#1

Create a new variable brian and assign it the string "Hello life!".
1/16 exercise of python

I am struck here
I have tried
name = "brain"

I still keep on getting error message as did you create variable called brain
Please help me try make combinations does not work.


#2

I will use your code as an example, ok? :smile:

name = "brain"

This code creates new variable (or if this variable exists it just assigns new value) called name and sets its value to string "brain".

So, the left side of the operation is a name of the variable, right side is the value.

Instructions says:

Create a new variable brian and assign it the string "Hello life!"

Left side of operation should be brian and the right side "Hello life!".

If this explanation is insufficient just let me know.


#3

Thanks for your response.

I tried
brain = "Hello life!"

But still I receive the same error - Did you create variable called brain


#4

According to instructions and to the error message:

"Did you create a variable called brian?"

It should be brian, not brain.


#5

Yes I created the variable brian
Heres my program

variable = brian
brian = "Hello life!"

still same error


#6

What is the purpose of the first line of your code.

At this line variable brian is undefined, so it causes an error.

Your second line is correct, but you should delete the first line.

Sorry, but I don't think that I can help you. You definitely should get back to the first section of this course -> https://www.codecademy.com/courses/introduction-to-python-6WeG3/0/2


#7

I found the answer...

var = "brian"
brian = "Hello life!"


#8

What is the purpose of the first line of your code?


#9

You are setting your first variable to "brian" like it asked in the directions.
"Create a new variable brian"


#10

Instruction says:

Create a new variable brian and assign it the string "Hello life!".

All you need is:

brian = "Hello life!"

Nothing more :smile:

Your first line creates variable var, not variable brian and you have set its value to "brian", but this line is completely redundant.


#11

But my answer still works too sooooo.


#12

Sure, kudos.

But don't you think that we all should try to give the best possible answers? That is the reason why I have written my comment.

You have created two variables because you forgotten the correct syntax. I understand this, but I didn't write my comment to offend you in any way. I just think that it might be kind of dangerous to share badly written code as a correct answer :smile:


#13

Along with that factoradic said, if you want to create multiple variable you cant do
var = "name"
name = "thing"
var = "another_name"
another_name = "another thing"

since that will just change the first 'var' to the second one.

also all it does it create a useless variable


#14

brian = "Hello life"


#15

All I keep getting is

Oops, try again. It seems that Brian has value "Hello life." instead of "Hello life."

I can't move on even though I have tried refreshing, rewording, capitals, lower case, commas, full stops, exclamation marks etc.


#16

Well, it should be "Hello life!", post your code.


#17

hi man am also stack here exercise 16 of python.help me please.
arcpro38645 arcpro38645
February 5
Code:
my_string="parrot"
Output
print len("My_String")
print my_string.upper()
in the console i get PARROT
9
none. why cant i continue please help ,me


#18

I think that you should print out length of string stored inside variable my_string.

So it should be:

print len(my_string)

my_string is a variable, "my_string" is string (a plain value).


#19

i kept having trouble with this too. What worked for me was:
brian="Hello life!"

^brian's name needs to be all lowercase.


#20

Hey guys. i had this same problem and i fixed it. On line 1 it says #Set the variable brian on line 3!
Make sure there is nothing else written before or after that comment of instructions. Otherwise you will get an error message. I think it's a typo error by code academy. Because it was like that when the lesson started even after refreshing it!

This is exactly how everything should look:
1 #Set the variable brian on line 3!
2
3 brian = "Hello life!"