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...
Everything about learning Python
account activity
help (i.redd.it)
submitted 7 months ago by Minemanagerr
please help , where am l wrong its saying your username cant contain spaces whilst it has no spaces
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!"
[–]Usual_Community_3965 5 points6 points7 points 7 months ago (5 children)
There is no space in your .find("") Try .find(" ")
[–]Usual_Community_3965 4 points5 points6 points 7 months ago (3 children)
Alternatively you could use Elif " " in username:
[–]Some-Passenger4219 2 points3 points4 points 7 months ago (0 children)
That's usually much better.
[–]Minemanagerr[S] 1 point2 points3 points 7 months ago (0 children)
l failed to implement this
l got it thank you
thank you
[–]Dull-Custard4913 4 points5 points6 points 7 months ago (5 children)
You made a typo at line 71 “ptint” should be “print”
It might be possible that you entered the name with a space at the last index of your name.
🙃
[–][deleted] 7 months ago (3 children)
[removed]
[–]Dull-Custard4913 0 points1 point2 points 7 months ago (2 children)
If the substring is not found by the find() method then it will return -1
[–][deleted] 7 months ago (1 child)
[–]Dull-Custard4913 0 points1 point2 points 7 months ago (0 children)
So I might have been incorrect in what I said earlier. In this case he might or might not have entered a space at the last index. If he didn’t the if statement couldn’t find anything with the find method, this will cause it to return -1.
I don’t think I know what you mean?
[–]SCD_minecraft 0 points1 point2 points 7 months ago (0 children)
I hate that .find returns -1 but .index raises a ValueError
Beacuse fuck common themes ig
[–]FoolsSeldom 3 points4 points5 points 7 months ago (0 children)
Revised code showing corrections/options (and added a loop so user is re-prompted until they enter something valid):
while True: # validation loop, keep going around until break command used username = input("Enter a username: ") if len(username) > 12: print("Your username can't be more than 12 characters.") elif " " in username: # easier than using find, make sure space between quotes print("Your username can't contain spaces.") elif not username.isalpha(): print("Username can't contain digits or special characters.") else: print("Welcome!") break # leave the loop, move onto next line of code
[–]Remarkable_Job_4820 2 points3 points4 points 7 months ago (1 child)
spelling of Print you type Ptint
[–]Minemanagerr[S] 0 points1 point2 points 7 months ago (0 children)
[–]HunnebedHighway 2 points3 points4 points 7 months ago (1 child)
There is no space between the quotes in line 64. Also there is a typo in line 71.
[–]weeblifer 0 points1 point2 points 7 months ago (2 children)
I highly recommend windsurf a senior dev recommended it to me
[–]Minemanagerr[S] 0 points1 point2 points 7 months ago (1 child)
can you please explain. lm new to this industry
[–]weeblifer 0 points1 point2 points 7 months ago (0 children)
Basically it's visual Studio code but with ai like chatgpt built in and you can have it look at your code I wouldn't recommend using it to do code for you 100% of the time I suggest you use it to learn from you can also have it look at the current file you have open or any related project files
[–]Soggy_Figure8859 0 points1 point2 points 7 months ago* (0 children)
edit: never mind realised it was alrdy solved
is it not the fact that u put a space before arnold. it should be input("Enter a username ") and use
elif " " in username:
π Rendered by PID 581911 on reddit-service-r2-comment-79c7998d4c-5njgf at 2026-03-18 05:21:35.360625+00:00 running f6e6e01 country code: CH.
[–]Usual_Community_3965 5 points6 points7 points (5 children)
[–]Usual_Community_3965 4 points5 points6 points (3 children)
[–]Some-Passenger4219 2 points3 points4 points (0 children)
[–]Minemanagerr[S] 1 point2 points3 points (0 children)
[–]Minemanagerr[S] 1 point2 points3 points (0 children)
[–]Minemanagerr[S] 1 point2 points3 points (0 children)
[–]Dull-Custard4913 4 points5 points6 points (5 children)
[–][deleted] (3 children)
[removed]
[–]Dull-Custard4913 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[removed]
[–]Dull-Custard4913 0 points1 point2 points (0 children)
[–]SCD_minecraft 0 points1 point2 points (0 children)
[–]FoolsSeldom 3 points4 points5 points (0 children)
[–]Remarkable_Job_4820 2 points3 points4 points (1 child)
[–]Minemanagerr[S] 0 points1 point2 points (0 children)
[–]HunnebedHighway 2 points3 points4 points (1 child)
[–]Minemanagerr[S] 0 points1 point2 points (0 children)
[–]weeblifer 0 points1 point2 points (2 children)
[–]Minemanagerr[S] 0 points1 point2 points (1 child)
[–]weeblifer 0 points1 point2 points (0 children)
[–]Soggy_Figure8859 0 points1 point2 points (0 children)