#๐Ÿ”’ i am noob

46 messages ยท Page 1 of 1 (latest)

upper linden
#

i am making this program and i need a function that can check if a varible has a number in it.

so if x = abcd1 then the program can return true of something

but if x = abcd then it can return false

north egretBOT
#

@upper linden

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

pallid nest
#

Have you learned about for loops

upper linden
#

actuallt yeah thats smart

#

so basically i have a value called like k-10

#

and i want to just turn the value into 10

pallid nest
#

Wdym?

upper linden
#

into a seperate varible

#

so x = K-10

#

but it can change

pallid nest
#

Wdym by that

upper linden
#

randonmly x could be = K-9 to K-1

pallid nest
#

x = K-10?

hollow socket
#

the variable contains string right

#

can be anything like

#

"sdflksdh123lksjdflk" ?

upper linden
#

yeah

hollow socket
#

you can do regex

upper linden
#

but just print a varible of only the numbers

#

so 123

#

what is regex

hollow socket
#

or loop . Might be easier

pallid nest
#

No need for regex if you are beginning

#

Just use a for loop

upper linden
#

ok

pallid nest
#

Do you know how to check if a single character is a number

hollow socket
#

do you know how to loop string?

upper linden
#

yes

pallid nest
#

Then you should be set

hollow socket
#

yea do that and check each one

pallid nest
hollow socket
#

aight

upper linden
#

hahha

pallid nest
#

Let us know if any more questions pop up or if you have more rn

upper linden
#

no its all goods

#

thanks

#

i have got it to do what i want

#

with a loop

#

but it prints each number in a new line

#

maybe .strip() would work

hollow socket
#

you can store the numbers in a new variable to be printed later

upper linden
#

yeah ill figure it out

#

thanks guys

pallid nest
#

Alright good luck

north egretBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.