ユーザー名を確認するプログラムを作成することになっていました。ユーザー名は8〜15文字以上で、英数字の値は使用できません。だから、あなたは数字と文字だけを持つことができます。最初または最後に数字を付けることはできません。そして、少なくとも1つの大文字と小文字と少なくとも1つの数字を持っていなければなりません。私はすべてのことをする方法を持っていますが、プログラムに大文字が含まれているかどうかを確認する方法を知っています。私は "ではない"しかし運がないことを試みた。これは私がこれまで持っていたものです。文字列に大文字が含まれているかどうかを確認してください。
username = input("please enter a name: ")
for i in username:
while len(username) < 8 or len(username) > 15:
print("Password is too long or too short")
username = input("please enter a name: ")
j = 31
while j < 47:
j += 1
while chr(j) in i:
print("No alphanumeric values allowed.")
username = input("please enter a name: ")
k = 57
while k < 64:
k += 1
while chr(k) in i:
print("No alphanumeric values allowed.")
username = input("please enter a name: ")
l = 47
while l < 57:
l += 1
while chr(l) in username[0]:
print("you cannot have a number in the beggining")
username = input("please enter a name: ")
while chr(l) in username[-1]:
print("you cannot have a number in the end")
username = input("please enter a name: ")
を満たしている場合は、あなたの質問は正確には何ですか? –
この前の投稿はあなたを助けます: http://stackoverflow.com/questions/6602111/how-to-search-for-a-capital-letter-within-a-string-and-return-the-list- – nbryans
なぜキーコードを使用していますか?明らかにこれを行うためのより良い方法があります。 – Laurel