Hello, I am brand new to python and I am highly willing to learn it. The problem is that I've been set homework on Tuples and I feel I've not been prepared well enough for it. Generally struggling to take any new information in this pandemic and I spent hours researching information and I still feel clueless.
The code at hand is here:
The code at hand is here:
def string_fun(string): ''' Return a tuple with three elements. The first element is True if the string contains only alphabet characters, otherwise False. The second element is True if the string ends with an exclamation mark ('!'), otherwise False. The third element is the string with all spaces (' ') replaced with hyphens ('-'). Arguments string: a string Examples string_fun('Hello World!') returns (False, True, 'Hello-World!') string_fun('ThisIsAChallenge') returns (True, False, 'ThisIsAChallenge') ''' # ==================================== # Do not change the code before this # CODE1: Write code that will assign details with the appropriate tuple # ==================================== # Do not change the code after this return details if __name__ == '__main__': print(string_fun('Hello World!')) print(string_fun('ThisIsAChallenge')) ------------------------------------------------ From my interpretation of Code 1, I tried details = (True, False, '-') for alpha in details: if string_fun.isalpha(): print(details[0]) else: print(details[1]) for symbol in details: if string_fun.endswith('!'): print(details[0]) else: print(details[1])Once I submit my answers it does not tell me if I am on the right track. It either says correct or wrong since it's marked by a computer and not a person. I'd like to know what to do because I feel clueless and also what is the correct code for this. P.S I am missing code for the final element which is replacing a space in the string with the hyphen element.
buran write Jan-28-2021, 12:06 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.