0
print error
age = int(input("Enter your age: ")) beloow = 18 - age above = age - 50 if age <18 : print (" You can't drive beacuse yoy need ", beloow " year to be a driver" ) elif age >50 : print (" You can't drive , because you are", above "year more to be a driver" ) elif age ==18 or age==50: print ("You can drive , beause you are ", age "year old") else: print (" You can drive , beause you are ", age " old which is between 18 and 50")
4 ответов
+ 1
The method is called "string formating or formated string" it enable you to mix string and variable together without throwing an error message.
Here is how to use it.
First use the f keyword before your quotation marks anything in between the quotation mark will be treated a string (like your normal string).
Second to add a variable use {} and write the name of the variable you want in that position (e.g {beloow})
Sorry for the bad explanation.
Hope you get it?
0
#This is how the code should go
age = int(input("Enter your age: "))
beloow = 18 - age
above = age - 50
if age <18 :
print (f" You can't drive beacuse you need {beloow} year to be a driver" )
elif age >50 :
print (f" You can't drive because you are {above} year more to be a driver" )
elif age ==18 or age==50:
print (f"You can drive, beause you are {age} year old")
else:
print (f" You can drive , beause you are {age} old which is between 18 and 50")
0
Why there is (f) in front of "you and thanks a lot for helping and giving your time
0
Thank you so much brother.... I really appreciate your help... your explanation is perfect.... I got it now fully😊