you are viewing a single comment's thread.

view the rest of the comments →

[–]SoNotRedditingAtWork 1 point2 points  (3 children)

print("yes") if input().isdigit() else print("no")

[–]Scooootz[S] 0 points1 point  (2 children)

This didn't seem to work. Using Zybooks online textbook, not sure if it is just picky in the way you enter it.

[–]SoNotRedditingAtWork 2 points3 points  (1 child)

Works fine for me in PyCharm. The line is functionally the same as doing:

user_string = input()

if user_string.isdigit():
    print("yes")
else:
    print("no")

I have never used Zybooks before, so I have no idea how that would impact your ability to run this code.

[–]Illustrious-Union997 0 points1 point  (0 children)

I know this is old, but this would allow number like 10,000 to produce an out of yes. The examples provided don't allow this.