Python Raw_input With Forced TLD?
I am working on a program that checks hostnames of specific sites, and I want to be able to insure that when asked for the hostname (with raw_input) it ends in a TLD (.com, .net, .
Solution 1:
endswith(suffix[, start[, end]])
will do the trick. Documentation
Please also note that suffix can be a tuple of suffices!
TLD = ('.com', '.info', '.org', '.net')
if raw_input("Please enter a hostname").endswith(TLD):
# blah blah
Post a Comment for "Python Raw_input With Forced TLD?"