wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
print 'info' | print('info') | print needs parentheses. | Python |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if ($z = 17) | if ($z == 17) | Use ==. | Perl |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
disp('data') | disp('data') | Correct. | MATLAB |
let text1 = String::from("world"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
for (int i=0; i<98; i++) {{}} | for (int i=0; i<98; i++) {{}} | Correct. | Java |
let num = 59; | let num = 59; | Correct. | JavaScript |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
JOIN profiles ON items.id = profiles.id | JOIN profiles ON items.id = profiles.id | Correct. | SQL |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
items(60) | if length(items) >= 60, items(60), end | Check length. | MATLAB |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
$arr[98] = 5; | if (isset($arr[98])) $arr[98] = 5; | Check existence. | PHP |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
data[67] | if data.indices.contains(67) {{ data[67] }} | Check index. | Swift |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
print 'info' | print 'info'; | Add semicolon. | Perl |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
let z = 'value' | let z = "value" | Double quotes. | Swift |
h1 {{ font-size:54px color:blue; }} | h1 {{ font-size:54px; color:blue; }} | Add semicolon. | CSS |
var val int = 'message' | var val string = 'message' | Type mismatch. | Go |
<input type='text' value='data'> | <input type='text' value='data' name='title'> | Add name attribute. | HTML |
if num = 62 | if num == 62 | Use ==. | Go |
val foo = 90; foo = 85 | var foo = 90; foo = 85 | Use var for reassignment. | Scala |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
int num = 'hello'; | String num = 'hello'; | Type mismatch. | Dart |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
class Product {{ int result; }}; | class Product {{ public: int result; }}; | Make public. | C++ |
while x > 70
x -= 1 | while x > 70:
x -= 1 | Colon missing after while. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
$count = 82; if ($count = 82) {{}} | $count = 82; if ($count == 82) {{}} | Use ==. | PHP |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
["value", 54] | ["value", 54] | Correct. | JSON |
function render(b:string){{return b;}} render(17); | function render(b:string){{return b;}} render('output'); | Pass correct type. | TypeScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
SELECT * FROM users WHRE age=13; | SELECT * FROM users WHERE age=13; | Fix WHERE. | SQL |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:26}}; | Add missing property. | TypeScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
WHERE email = '43' | WHERE email = 43 | Don't quote integer. | SQL |
{{'value':77, 'status' 77}} | {{'value':77, 'status':77}} | Colon missing. | Python |
String temp = 'data'; | String temp = "data"; | Double quotes. | Java |
if (temp = 38) {{}} | if (temp === 38) {{}} | Use === for equality. | JavaScript |
.Product {{ color: #333; }} | .Product {{ color: #333; }} | Correct. | CSS |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
jwt.sign({{id:7}}, 'password'); | jwt.sign({{id:7}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
List(42,59,87) | List(42,59,87) | Correct. | Scala |
arr[29] | if (arr.indices.contains(29)) arr[29] | Check index. | Kotlin |
var x = 7; | var x = 7; | Correct. | Dart |
val val: Int = 'info' | val val: String = 'info' | Fix type. | Kotlin |
const y = 64; y = 7; | let y = 64; y = 7; | Cannot reassign const. | JavaScript |
'message' + 93 | 'message' + 93.to_s | Convert int. | Ruby |
let c: number = 'value'; | let c: string = 'value'; | Fix type. | TypeScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if temp = 97 {{}} | if temp == 97 {{}} | Use ==. | Swift |
// comment | /* comment */ | Use /* */. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if index = 90 then
print('value')
end | if index == 90 then
print('value')
end | Use ==. | Lua |
print('world') | print('world') | Correct. | R |
items[8] | if (length(items) >= 8) items[8] | Check length. | R |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
switch(num){{ case 52: break; }} | switch(num){{ case 52: break; default: break; }} | Add default case. | Java |
object User {{ def main(args: Array[String]) = println("hello") }} | object User {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
my @arr = (55,51,89); | my @arr = (55,51,89); | Correct. | Perl |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(76); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(76); | Correct. | Node.js |
y == '32' | y === 32 | Use strict equality. | JavaScript |
if ($x = 1) {{}} | if ($x -eq 1) {{}} | Use -eq. | PowerShell |
let z: number | null = null; z.toFixed(62); | let z: number | null = null; if(z!==null) z.toFixed(62); | Null check. | TypeScript |
name: result
age: 90 | name: result
age: 90 | Correct. | YAML |
DELETE FROM items WHERE id=47 | DELETE FROM items WHERE id=47; | Add semicolon. | SQL |
let index = 75; let index = 58; | let index = 75; index = 58; | Duplicate declaration. | JavaScript |
let data = 56; data += 1; | let mut data = 56; data += 1; | Need mut to modify. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
index = 71 | index=71 | No spaces. | Shell |
if (val = 88) {{}} | if (val == 88) {{}} | Use ==. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
switch(z){{ case 14: break; }} | switch(z){{ case 14: break; default: break; }} | Add default case. | Java |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
$list[65] = 5; | if (isset($list[65])) $list[65] = 5; | Check existence. | PHP |
my @arr = (83,43,61); | my @arr = (83,43,61); | Correct. | Perl |
[47, 34, 46 | [47, 34, 46] | Close bracket. | Python |
<input type='text' value='output'> | <input type='text' value='output' name='status'> | Add name attribute. | HTML |
if val = 88 then
print('value')
end | if val == 88 then
print('value')
end | Use ==. | Lua |
else
print('data') | else:
print('data') | Colon after else. | Python |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(60); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(60); | Correct. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.