user2372443
user2372443

Reputation: 27

replace a lists in a list of lists in mathematica

I have a list of lists, similar to what is below, I need to replace each {"S","D","U"} list in the overall list with a number.. Thanks in advance!

A = {{"S", "D", "U"}, {"S", "D", "U"}, {"S", "D", "U"}, {"S", "D", 
  "U"}, {"S", "D", "U"}, {"S", "D", "U"}, 1, {"S", "D", "U"}, {"S", 
  "D", "U"}, {"S", "D", "U"}, {"S", "D", "U"}, {"S", "D", "U"}, {"S", 
  "D", "U"}, {"S", "D", "U"}, {"S", "D", "U"}, {"S", "D", "U"}, {"S", 
  "D", "U"}, 1, {"S", "D", "U"}}

Upvotes: 1

Views: 247

Answers (1)

Chris Degnen
Chris Degnen

Reputation: 8645

A /. {"S" -> 1, "D" -> 2, "U" -> 3}

Upvotes: 1

Related Questions