def main(): plate = input("Plate: ") if is_valid(plate): print("Valid") else: print("Invalid") #Much like a list, a str is a “sequence” (of characters), which means it can be “sliced” into shorter strings with syntax like s[i:j]. For instance, if s is "CS50", then s[0:2] would be "CS". #str.isalnum() eturn True if all characters in the string are alphanumeric and there is at least one character, False otherwise. # Alfanümerik, A ile Z arasındaki harfler ile 0 – 9 arasındaki rakamları kapsayan karakter topluluğudur def is_valid(s): n=0 if 2<=len(s)<=6: for k in s: if k.isalnum(): for i in s[0:2]: if i.isnumeric(): return False for j in s: if n==0 and j=="0": return False else: if j.isnumeric(): n=1 elif n==1 and j.isnumeric()==False: return False else: return False return True else: return False main()
deanhystad write Jun-14-2024, 08:43 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Attached Files