Hello community,

I am trying to solve this issue using Python in help with IF statement. I am trying to print the statement : “Alexia has found an extra apple and now she has more fruits in the basket” every time one student find a new fruit. Technically here, Alexia and apple are two variables. So my code will be:

if x == "" or y == "":
    print( x,  "has found an extra apple and now she has more fruits in the basket", y)

Any help with this?

Hey there and welcome to the forums!! :slightly_smiling_face:

I’m not quiet sure how you are obtaining information here, could you post your full code for more context?
How are you wanting your logic to work? What do you have to work with? Is there a variable that becomes True when someone finds an apple?

If a random generator is deciding if an apple is found than you could have its result saved and then compare that.

Hello @8-bit-gaming,

Thank you for replying. I might have done a mistake in the previous message but I want to start with a code on python that prints the statement print( x, “has found a(n)”, y “and now she/he has” , z, " fruits in the basket") knowing that x (student name) , y (fruit found by the student) and z (total number of fruits the student has now) are constantly changing. In other words, imagine we have a group of students looking for different fruits in the garden, every time a student finds a fruit we then input that in the machine and now the student has more fruits in the basket. For instance, saying that Brian has found one apple the first time then now he found an orange, then the statement will print out Brian has found an orange and now he has 2 fruits in the basket. I hope that makes a better sense. But the names, the fruit names and the numbers are constantly changing. I wasn’t sure if I had to input these info every time. Please help!

My apologies for a late response. There are a lot of different ways to format strings for printing in Python and I’d recommend doing some research on it.

One of my personal favorite ways are the f strings, which allow you to place values inside a string surrounded by curly brackets. For example:

name = "Bob"
fruit = "pear"
print(f"{name} found a {fruit}!")
Bob found a pear!