Python Forum
Help with the string and len quiz
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with the string and len quiz
#1
given_name = "Charlotte"
middle_names = "Hippopotamus"
family_name = "Turner"

name_length = #todo: calculate how long this name is

driving_licence_character_limit = 28
print(name_length <= driving_licence_character_limit)
Reply
#2
Please post your code along with any errors you might encounter between the proper BBCode tags.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
In Python the len() function will tell you how long a string is:

len("this is  string")
You can assign the returned value to a variable, or use it anywhere you would normally use a number or variable.

and you can concatenate strings:
"one" + "two" + "three"
If you want to include a space between strings, use " ":
"one" + " " + "two"
Instead of "literals" you can reference any variables containing strings.
I am trying to help you, really, even if it doesn't always seem that way
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020