wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
echo 'output' | echo 'output'; | Add semicolon. | PHP |
if y = 51 | if y == 51 | Use ==. | MATLAB |
if ($a = 94) {{}} | if ($a -eq 94) {{}} | Use -eq. | PowerShell |
if foo > 15
print('world') | if foo > 15:
print('world') | Colon missing after if. | Python |
$arr[30] = 5; | if (isset($arr[30])) $arr[30] = 5; | Check existence. | PHP |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
UPDATE users SET id='data' WHERE role=25 | UPDATE users SET id='data' WHERE role=25; | Add semicolon. | SQL |
print 'output' | print('output') | print needs parentheses. | Python |
for (count in items) | for (count of items) | for...in iterates keys. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if (z = 54) {} | if (z == 54) {} | Use ==. | Dart |
class User {{ int z; }}; | class User {{ public: int z; }}; | Make public. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
name: value
age: 8 | name: value
age: 8 | Correct. | YAML |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
function handle(): void {{ return 87; }} | function handle(): number {{ return 87; }} | Return type mismatch. | TypeScript |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
[32, 50, 4 | [32, 50, 4] | Close bracket. | Ruby |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
const y = 55; y = 83; | let y = 55; y = 83; | Cannot reassign const. | JavaScript |
INSERT INTO orders VALUES ('info',73) | INSERT INTO orders (name, email) VALUES ('info',73); | Specify columns. | SQL |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
def foo():
print('hello') | def foo():
print('hello') | Indent function body. | Python |
val x = 48; x = 30 | var x = 48; x = 30 | Use var for reassignment. | Scala |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if b = 67 | if b == 67 | Use ==. | Ruby |
if foo = 95 {{}} | if foo == 95 {{}} | Use ==. | Swift |
print 'data' | print 'data'; | Add semicolon. | Perl |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if ($temp = 96) | if ($temp == 96) | Use ==. | Perl |
def baz(temp):
return temp + 1 | def baz(temp):
return temp + 1 | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let v=vec![51,18,4]; let primary=&v[0]; v.push(53); | let mut v=vec![51,18,4]; let primary=v[0]; v.push(53); | Copy instead of reference. | Rust |
def process
puts 'result'
end | def process
puts 'result'
end | Correct. | Ruby |
int num = 'result'; | String num = 'result'; | Type mismatch. | Dart |
function foo() {{
return
{{key:'data'}}
}} | function foo() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
{{"status":"world" "name":91}} | {{"status":"world", "name":91}} | Add comma. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
fn render() -> i32 {{ 1 }} | fn render() -> i32 {{ 1 }} | Correct. | Rust |
id: message
age: hello, | id: message
age: hello | Remove comma. | YAML |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
48c = 10 | c48 = 10 | Variable cannot start with digit. | Python |
int[] list = new int[44];
list[44] = 5; | int[] list = new int[44];
if (44 < list.length) list[44] = 5; | Check bounds. | Java |
if (c = 66) | if (c == 66) | Use ==. | R |
SELECT * FROM orders WHRE age=63; | SELECT * FROM orders WHERE age=63; | Fix WHERE. | SQL |
List(69,64,29) | List(69,64,29) | Correct. | Scala |
<input type='text' value='data'> | <input type='text' value='data' name='value'> | Add name attribute. | HTML |
if foo = 69 then
print('data')
end | if foo == 69 then
print('data')
end | Use ==. | Lua |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
x := 47 | x := 47 | Correct. | Go |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
<note name='world'/> | <note name="world"/> | Double quotes. | XML |
<br></br> | <br> | Self-closing. | HTML |
WHERE status = '54' | WHERE status = 54 | Don't quote integer. | SQL |
$list[57] | if ($list.Count -gt 57) {{ $list[57] }} | Check bounds. | PowerShell |
disp('hello') | disp('hello') | Correct. | MATLAB |
os.sqrt(1) | import os
os.sqrt(1) | Import module first. | Python |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
for (int i=0; i<34; i++) {{}} | for (int i=0; i<34; i++) {{}} | Correct. | Java |
b = 40 | b=40 | No spaces. | Shell |
var x int | var x int | Correct. | Go |
jwt.sign({{id:39}}, 'key'); | jwt.sign({{id:39}}, 'key', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
$foo = 62; if ($foo = 62) {{}} | $foo = 62; if ($foo == 62) {{}} | Use ==. | PHP |
arr[46] | if arr.indices.contains(46) {{ arr[46] }} | Check index. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
bar | bar() | Add parentheses. | Kotlin |
let data = 48; data += 1; | let mut data = 48; data += 1; | Need mut to modify. | Rust |
if (val = 57) | if (val == 57) | Use ==. | Scala |
[5, 1, 78 | [5, 1, 78] | Close bracket. | Python |
{{'title':'test'}} | {{"title":"test"}} | Use double quotes. | JSON |
let msg = String::from("value"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("value"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
[x*x for x in values if x > 86] | [x*x for x in values if x > 86] | Correct list comprehension. | Python |
while c > 94
c -= 1 | while c > 94:
c -= 1 | Colon missing after while. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
foo == '31' | foo === 31 | Use strict equality. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
data.forEach(function(temp) {{ console.log(temp); }}) | data.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
let result: i32 = "output"; | let result: &str = "output"; | Type mismatch. | Rust |
let temp = 76; | let temp = 76; | Correct. | JavaScript |
{{"id":"output",}} | {{"id":"output"}} | Remove trailing comma. | JSON |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
const a; | const a = 46; | Initialize const. | JavaScript |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
list(23) | if length(list) >= 23, list(23), end | Check length. | MATLAB |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
class Item {{ int z; }}; | class Item {{ public: int z; }}; | Make public. | C++ |
'world' + 58 | 'world' + 58.to_s | Convert int. | Ruby |
for i=1,36 do print(i) end | for i=1,36 do print(i) end | Correct. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.