Need help asking for an input sentence

3 ビュー (過去 30 日間)
Alex Skantz
Alex Skantz 2021 年 10 月 21 日
回答済み: Akira Agata 2021 年 10 月 21 日
Hi, I need to ask the user to insert a sentence. I have
N=input('what is N?: ')
A=input('give me a sentence!: ');
Once I run the code and insert any word I get an error that says invalid expression. How can I stop the error from popping up? I will also be asking the sentence prompt to repeat until a certain word or phrase is typed.

回答 (1 件)

Akira Agata
Akira Agata 2021 年 10 月 21 日
To input a text, you should use 's' option, like:
N = input('what is N?: ')
A = input('give me a sentence!: ','s');

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by