Python Forum
How to convert value to defined number?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to convert value to defined number?
#5
# User input
rightNotes = "c4 e4 g4 c5"
# Convert user input to numbers
text2Numbers = {'c4': 40, 'e4': 44, 'g4': 47, 'c5': 52}
rightNotesList = rightNotes.split()
print(rightNotesList)
# Question: how to transport and convert the text from rightNotesList from text2Numbers in the
# rightNumbers list?
rightNumbers = []
print('converted numbers:')
print(rightNumbers)
# Desired result in this example:
# [40, 44, 47, 52]
# If rightNotes(user input) is for example 'c4' the output should be '[40]'.
After I understand this I can make the full dictionary for all musical pitches!
Reply


Messages In This Thread
RE: How to convert value to defined number? - by philipbergwerf - Dec-08-2019, 08:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  convert % to a number Nickd12 2 2,094 Sep-18-2020, 12:18 AM
Last Post: deanhystad
  python library not defined in user defined function johnEmScott 2 3,914 May-30-2020, 04:14 AM
Last Post: DT2000
  Find Average of User Input Defined number of Scores DustinKlent 1 4,372 Oct-25-2019, 12:40 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020