[Tutor] Python
Alan Gauld
alan.gauld at yahoo.co.uk
Wed May 17 16:37:52 EDT 2023
First, you only need to post once. It will sit in the moderation
queue until accepted but it will get here eventually (usually
within a few hours).
On 17/05/2023 15:15, Umut Çağlar Günlü wrote:
> // UNFORTUNATELY, THE CODE DOESN'T COMPILE WHAT I REQUEST.
> // I AM THINKING THAT THE PROBLEM IS IN THE COMPILER OF
> // PYCHARM. WHAT SHOULD I DO?
A compile error would produce an error - usually a syntax errror.
It looks like your code is compiling fine. The error is that
the result is not what you expected.
Unfortunately your code has lost indentation (you must post
in plain text to retain indentation) so it is hard to know
what might be wrong.
> def hint_username(username):
> if len(username) < 3:
> print("Invalid username. Must be at least 3 characters long.")
> elif len(username) > 15:
> print("Invalid username. Must be at most 15 characters long.")
> else:
> print("Valid username.")
>
> hint_username("umutcaglargunsimafatehian")
>
> -----------------------------------------------------------------
>
> /Users/umutcaglargunlu/PycharmProjects/pythonProject6/venv/bin/python
> /Users/umutcaglargunlu/PycharmProjects/pythonProject6/main.py
> Invalid username. Must be at least 3 characters long.
>
> Process finished with exit code 0
At first glance I don't see any code errors(assuming the indentation
is sane). What happens if you save the file and run it from the
Python interpreter at the command line?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list