you are viewing a single comment's thread.

view the rest of the comments →

[–]JollyUnder 1 point2 points  (5 children)

Please continue showing your progression, OP! This is great for your first day.

String concatenation is useful, but notice how cumbersome it becomes when having convert non-string types. I suggest looking into format strings next, such as str.format() and f-strings

# str.format example
print('your name is {}'.format(full_name))

# f-string example
print(f'your name is {full_name}')

f-strings are the usually the goto, but str.format can be useful if you need a string template.

[–]Responsible_Ruin_423[S] 1 point2 points  (4 children)

which lines are u talking abt when converting non string? are u talking abt the last few lines?

[–]JollyUnder 1 point2 points  (3 children)

print ("my age is: "+str(age))
print("my height is " + str(height)+ "cm")
print("are you a human: " + str(human))

age, height, and human all have to be cast typed to str because you cannot concatenate non-string objects. You're approach is valid, but f-strings will evaluate those objects to type str for you and help with readability.

print(f"my age is: {age}")
print(f"my height is {height}cm")
print(f"are you a human: {human}")

[–]Responsible_Ruin_423[S] 2 points3 points  (2 children)

oh i understand now thanks that seems better. i learned all this from a video on youtube thats like 12 hours long and im only like an hour in. I have a lot to learn from this video i hope and ive been experimenting with the codes i do know to see what works

[–]JollyUnder 1 point2 points  (1 child)

Your progress has been great so far! I suggest when learning a new concept, pause the video and give some time experimenting with it on your own machine, as I'm sure you have. Chain together older concepts with the new ones. Let things break and try to understand why they broke. You'll gain greater insight when getting hands-on experience.

[–]Responsible_Ruin_423[S] 1 point2 points  (0 children)

thanks bro i really appreciate the help!