Python questions beginner | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python questions beginner

1 . Can I use inside a string method a variable ? Exemple: if I want to check if a word input from user which is a string match with an specific word from an longer text 2.On line with return keyword can I use print too ?

22nd Aug 2022, 10:01 AM
Andrei Macovei
Andrei Macovei - avatar
4 Answers
+ 4
1. Yup. It sounds like you use some kind of substring method or even the 'in' keyword. 2. Yup, but I'm not sure if that's good practice because it might be what's called a side effect. So may just want to return the string itself and then have the main function do the printing for you.
22nd Aug 2022, 10:20 AM
Justice
Justice - avatar
+ 2
Justice Thank you !
22nd Aug 2022, 10:21 AM
Andrei Macovei
Andrei Macovei - avatar
0
No probs! 😁
22nd Aug 2022, 12:33 PM
Justice
Justice - avatar
0
I was too wondering the same thing, can you send me your code in case you have the answer.
24th Aug 2022, 10:14 AM
Derrick Okello