Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
2

Print or len?

JdoublelL
JdoublelL

I am a beginner to Python; I know absolutely nothing. I'm exposing myself to a free course in order to see if coding is something I want to pursue.

I was give tasks and a final assignment and something doesn't seem to be adding up.

The assignment states:

Create a new repl session called module_1_printing.py. In it, print a sentence of your choosing. Then, print the length of that sentence. Do this 3 more times. Next, print the only two boolean values that exist. Lastly, print the integer 54321, and then print its Python type.

I started by completing the first task: print a sentence of your choosing.

print ("I will learn Python!")

it formulated as it should ;)

Next it asked me: Then, print the length of that sentence.
( I'm assuming it's asking for me to use the "len" function) so I went ahead and did .....

len("I will learn Python!")

But when hitting "run" nothing happened. It didn't tell me how long the string is.

What am I doing wrong???? HELP!!!!!!

module_1_printing_python

3 years ago

Voters

Comments

TopNew
2

You need to store the length of your sentence in a variable e.g. sentence_length = len("I will learn Python!"), then print the length using print e.g. print("The length of the sentence is", sentence_length).

You can print the type of a variable using the type function, like so:

age = 17 name = "Joe Bloggs" print("Here are the types", "age", type(age), "name", type(name))
3 years ago
1
gregory54
gregory54

I'm glad I discovered this web site, I couldn't find any knowledge with this matter prior to.Also operate a site and if you're ever thinking about doing some visitor writing for me if at all possible feel free to i'd like to know, im always try to find people to check out my web site. flyttebyrå Oslo

3 months ago
1
migoyo
migoyo

Took me time to read most of the comments, but I truly enjoyed the article. It turned out to be Beneficial to me and I am sure to all or any the commenters here! It's always nice when you're able to not only be informed, but also entertained! เว็บแทงบอลที่ดีที่สุด

3 months ago
1
UmidQulameliyev
UmidQulameliyev

a program that finds the number of characters in a sentence

1 year ago
Load more