I Am the Walrus" is a 1967 song by The Beatles, written by John Lennon and credited to Lennon/McCartney. Lennon claimed he wrote the first two lines on separate acid trips. The song was in the Beatles' 1967 television film and album Magical Mystery Tour, and was the B-side to the #1 hit "Hello, Goodbye".
Lennon composed the avant-garde song by combining three songs he had been working on. When he learned that a teacher at his old primary school was having his students analyse Beatles' lyrics, he added a verse of nonsense words.
The walrus is a reference to the walrus in Lewis Carroll's "The Walrus and the Carpenter" (from the book Through the Looking-Glass). Lennon expressed dismay upon belatedly realising that the walrus was a villain in the poem.
The genesis of the lyrics is found in three song ideas that Lennon was working on, the first of which was inspired by hearing a police siren at his home in Weybridge; Lennon wrote the lines "Mis-ter cit-y police-man" to the rhythm of the siren. The second idea was a short rhyme about Lennon sitting in his garden, while the third was a nonsense lyric about sitting on a corn flake. Unable to finish the ideas as three different songs, he combined them into one.