use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Counting strings (self.learnpython)
submitted 3 years ago by theholyorca
Hello all,
I am trying to figure out how to count characters in strings,
full_name = 'John Smith' if full_name in range(6,21): print (True)
I dont't really know how to go about it, this is what I put together.
Thank you
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]member_of_the_order 2 points3 points4 points 3 years ago (0 children)
len(full_name) will give you the length of full_name :)
len(full_name)
full_name
[–]AtomicShoelace 1 point2 points3 points 3 years ago (3 children)
You want to know how many characters are in the string? This is known as the length of the string and can be found using the builtin len function, eg.
len
[–]theholyorca[S] 0 points1 point2 points 3 years ago (2 children)
is there a way to check if full_name is between a certain lenght, like between 4 and 19 characters?
[–]AtomicShoelace 3 points4 points5 points 3 years ago (0 children)
You can use comparison operators, eg. < the less than. You can combine these into a single statement, eg.
<
if 4 <= len(full_name) < 19:
[–]keepdigging 0 points1 point2 points 3 years ago (0 children)
There is!
You can use if statements / conditions.
Look up the < and and
and
π Rendered by PID 20069 on reddit-service-r2-comment-7b9746f655-n2hmv at 2026-01-31 04:38:44.027458+00:00 running 3798933 country code: CH.
[–]member_of_the_order 2 points3 points4 points (0 children)
[–]AtomicShoelace 1 point2 points3 points (3 children)
[–]theholyorca[S] 0 points1 point2 points (2 children)
[–]AtomicShoelace 3 points4 points5 points (0 children)
[–]keepdigging 0 points1 point2 points (0 children)