0
Character in input
""" write a code that decides if the input can be divided by 3 and/or 5 without remainder""" x = int(input()) def threefive(): while x % 3 == 0 or x % 5 == 0: return True if x % 3 !=0 or x % 5 != 0: return False else: print("Invalid input!") print(threefive()) I'd like to know what should I write to the else: to output the "Invalud input!" when the input has character(s) in it? Thanks in advance!
2 Respostas
+ 3
Written like that it'll cause an error, so you'd just need a try and except block. If you don't want error you can take your input as string, check it with .isdigit() and then convert to an integer
0
Thank you!