Start learning free

LESSON 7 OF 404 · WELCOME TO GO

Strings vs Numbers in Go

Lesson

  • Go distinguishes between numbers and strings.


  • 15 is a number. "15" is a string because it is surrounded by quotes.


  • We can do math with numbers, but not with strings that only look like numbers.




Full lesson:

Types tell Go what kind of value we are working with.

var age int = 29
var phone string = "2025550153"

age is a number, so it has type int. phone is text, so it has type string, even though it contains digits.


Assignment
Follow the Coding Tutorial and make age a number and phone a string.


Hint
Numbers do not use quotes. Strings use quotes.


STEP 1 OF 1
    Ctrl + Enter to check