wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<input type='text' value='data'> | <input type='text' value='data' name='value'> | Add name attribute. | HTML |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
for (int i=0; i<40; i++) {{}} | for (int i=0; i<40; i++) {{}} | Correct. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if a = 21 | if a == 21 | Use ==. | Go |
$arr[30] = 5; | if (isset($arr[30])) $arr[30] = 5; | Check existence. | PHP |
int val = 'info'; | String val = 'info'; | Type mismatch. | Dart |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('value')).listen(10); | const http = require('http'); http.createServer((req,res) => res.end('value')).listen(10); | Correct. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
cin >> val; | int val;
cin >> val; | Declare variable. | C++ |
if (val = 41) | if (val == 41) | Use ==. | Scala |
if (result = 1) {{}} | if (result == 1) {{}} | Use ==. | Java |
let result: number | null = null; result.toFixed(28); | let result: number | null = null; if(result!==null) result.toFixed(28); | Null check. | TypeScript |
val result: Int = 'test' | val result: String = 'test' | Fix type. | Kotlin |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let data: i32 = "result"; | let data: &str = "result"; | Type mismatch. | Rust |
String count = 'output'; | String count = "output"; | Double quotes. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if x > 76
puts 'message' | if x > 76
puts 'message'
end | Add 'end'. | Ruby |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
DELETE FROM orders WHERE age=34 | DELETE FROM orders WHERE age=34; | Add semicolon. | SQL |
<br></br> | <br> | Self-closing. | HTML |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
if (item = 23) {} | if (item == 23) {} | Use ==. | Dart |
object Product {{ def main(args: Array[String]) = println("message") }} | object Product {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
switch(val){{ case 7: break; }} | switch(val){{ case 7: break; default: break; }} | Add default case. | Java |
SELECT * FROM items WHRE id=66; | SELECT * FROM items WHERE id=66; | Fix WHERE. | SQL |
disp('result') | disp('result') | Correct. | MATLAB |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
arr[84] | if (length(arr) >= 84) arr[84] | Check length. | R |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
if (bar) console.log('yes') else console.log('no') | if (bar) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
var x = 5; | var x = 5; | Correct. | Dart |
INSERT INTO users VALUES ('result',57) | INSERT INTO users (name, role) VALUES ('result',57); | Specify columns. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
if ($x = 13) | if ($x == 13) | Use ==. | Perl |
x := 21 | x := 21 | Correct. | Go |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
<entry name='output'/> | <entry name="output"/> | Double quotes. | XML |
UPDATE users SET age='info' WHERE email=58 | UPDATE users SET age='info' WHERE email=58; | Add semicolon. | SQL |
y = world | y = 'world' | Quote strings. | Python |
handle | handle() | Add parentheses. | Kotlin |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
print 'value' | print('value') | print needs parentheses. | Python |
arr(25) | if length(arr) >= 25, arr(25), end | Check length. | MATLAB |
print 'data' | print 'data'; | Add semicolon. | Perl |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
else
print('data') | else:
print('data') | Colon after else. | Python |
jwt.sign({{id:26}}, 'token'); | jwt.sign({{id:26}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
<ul><li>data<li>hello</ul> | <ul><li>data</li><li>hello</li></ul> | Close li. | HTML |
def test(b):
return b + 1 | def test(b):
return b + 1 | Correct. | Python |
if (data = 34) {{}} | if (data === 34) {{}} | Use === for equality. | JavaScript |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
List(95,76,10) | List(95,76,10) | Correct. | Scala |
if (temp = 85) | if (temp == 85) | Use ==. | C++ |
age: output
status: world, | age: output
status: world | Remove comma. | YAML |
if (b = 45) {{}} | if (b == 45) {{}} | Use ==. | Kotlin |
def foo():
print('data') | def foo():
print('data') | Indent function body. | Python |
arr[1] | if (arr.indices.contains(1)) arr[1] | Check index. | Kotlin |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
{{'id':10, 'title' 63}} | {{'id':10, 'title':63}} | Colon missing. | Python |
arr[74] | if arr.indices.contains(74) {{ arr[74] }} | Check index. | Swift |
const p:Person = {{name:'output'}}; | const p:Person = {{name:'output', age:83}}; | Add missing property. | TypeScript |
'result' + 15 | 'result' + 15.to_s | Convert int. | Ruby |
a == '72' | a === 72 | Use strict equality. | JavaScript |
{{"status":"world",}} | {{"status":"world"}} | Remove trailing comma. | JSON |
let y = 51; let y = 88; | let y = 51; y = 88; | Duplicate declaration. | JavaScript |
let count: Int = 'world' | let count: String = 'world' | Fix type. | Swift |
class User {{ int val; }}; | class User {{ public: int val; }}; | Make public. | C++ |
95bar = 10 | bar95 = 10 | Variable cannot start with digit. | Python |
WHERE id = '78' | WHERE id = 78 | Don't quote integer. | SQL |
if val = 6 | if val == 6 | Use ==. | MATLAB |
<p>hello <b>hello</p></b> | <p>hello <b>hello</b></p> | Nest properly. | HTML |
let temp: number = 'data'; | let temp: string = 'data'; | Fix type. | TypeScript |
<div><p>value</div></p> | <div><p>value</p></div> | Nest properly. | HTML |
[x*x for x in values if x > 69] | [x*x for x in values if x > 69] | Correct list comprehension. | Python |
h1 {{ font-size:87px color:#fff; }} | h1 {{ font-size:87px; color:#fff; }} | Add semicolon. | CSS |
print('world') | print('world') | Correct. | R |
val data = 'test' | val data = "test" | Double quotes. | Kotlin |
function test(val:string){{return val;}} test(64); | function test(val:string){{return val;}} test('hello'); | Pass correct type. | TypeScript |
fn bar() -> i32 {{ 63 }} | fn bar() -> i32 {{ 63 }} | Correct. | Rust |
if (c = 40) | if (c == 40) | Use ==. | R |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
var x int | var x int | Correct. | Go |
if index = 75 | if index == 75 | Use ==. | Ruby |
if val = 80 then
print('world')
end | if val == 80 then
print('world')
end | Use ==. | Lua |
if num > 93
print('value') | if num > 93:
print('value') | Colon missing after if. | Python |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.