Can ReadLine() be used in if statements. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can ReadLine() be used in if statements.

I want the user to input their ethnicity and then from what they enter it prints the out their home country. Any way how I can do this I tried using an if statement but no luck.

3rd May 2019, 7:28 AM
Zach Prozach
Zach Prozach - avatar
2 Answers
+ 2
Can you show us the code sample. Than we can help you with it.
3rd May 2019, 8:32 AM
Dragonxiv
Dragonxiv - avatar
+ 1
let ethnicity = readLine() if ethnicity == "African" { print("Africa") } if ethnicity == "Chinese" { print("china") }
3rd May 2019, 5:59 PM
Zach Prozach
Zach Prozach - avatar