Summarize the following:
Tap the app icon that has two silver gears on your iPhone or iPad home screen. You can get a verification code used to log in to other devices or https://www.icloud.com/ in the Settings app. It's at the top of the Settings app next to your profile image. On iOS 10.2 or earlier, you will need to tap iCloud first, and then tap your name. It's the second option at the top of the Apple ID menu. It's at the bottom of the Password & Security menu. A 6-digit security code will appear on-screen. Enter this 6-digit security code when asked to enter a verification code when signing in with your Apple ID.

Summary:
Open the Settings app . Tap your name. Tap Password & Security. Tap Get Verification Code.