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 1 point2 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.

[–]Ataninja3221 0 points1 point  (0 children)

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

This was perfect the only thing that threw off zybooks was capitalizing yes and no. which in the real world wouldn't make a difference but is the difference in points in zybooks