Python code to determine if TLD exists, prompt again if not?
问题 This is an additional question in regards to this post: Python raw_input with forced TLD? I have a check in place to see if a string ends with a TLD, TLD = ('.com', '.info', '.org', '.net') if raw_input("Please enter a hostname").endswith(TLD): # blah blah But I am attempting to store the raw_input in to a variable. Would the proper coding practice be to do something such as: TLD = ('.com', '.info', '.org', '.net') hostName = raw_input(":").lower() <<piece of code that determines if hostName