Member_2_7966113
asked on
Python Question on Databricks
Hello Experts,
I'm not sure if there are many Databricks experts on this site, but I'll ask anyway.
I have written the following code in Databricks
However, when I input 5 the number 5 the answer I get back is:
Please guess a number between 1 and 10:
However, I should get back the answer:
Well Done, matey, you guessed it
Can someone help figure out why
I'm not sure if there are many Databricks experts on this site, but I'll ask anyway.
I have written the following code in Databricks
dbutils.widgets.text("name", "Please Enter Your Name: ")
dbutils.widgets.text("age", "How old are you? ")
dbutils.widgets.text("guess", "Guess a Number")
name = dbutils.widgets.get("name")
age = int(dbutils.widgets.get("age"))
guess = int(dbutils.widgets.get("guess"))
print("Please guess a number between 1 and 10: ")
if guess < 5:
print("Please guess higher")
if guess == 5:
print("Well Done, matey, you guessed it!")
else:
print("Bad luck you guessed incorrectly")
However, when I input 5 the number 5 the answer I get back is:
Please guess a number between 1 and 10:
However, I should get back the answer:
Well Done, matey, you guessed it
Can someone help figure out why
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
is the following good or bad practice?I don't see much you could do as an alternative to what you've written without complicating it unnecessarily.
ASKER
Thanks
ASKER
You're answer is correct, however is the following good or bad practice?
Open in new window