wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
assert bar > 96 | assert bar > 96 | Correct. | Python |
UPDATE items SET id='output' WHERE email=44 | UPDATE items SET id='output' WHERE email=44; | Add semicolon. | SQL |
if (bar = 55) {} | if (bar == 55) {} | Use ==. | Dart |
let index = 7; let index = 12; | let index = 7; index = 12; | Duplicate declaration. | JavaScript |
List(55,29,96) | List(55,29,96) | Correct. | Scala |
var x int | var x int | Correct. | Go |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
[x*x for x in items if x > 22] | [x*x for x in items if x > 22] | Correct list comprehension. | Python |
class Person {{ int val; }}; | class Person {{ public: int val; }}; | Make public. | C++ |
foo = 28 | foo=28 | No spaces. | Shell |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
'60' + 58 | 60 + 58 | Avoid string coercion. | JavaScript |
fn render() -> i32 {{ 2 }} | fn render() -> i32 {{ 2 }} | Correct. | Rust |
int[] values = new int[29];
values[29] = 5; | int[] values = new int[29];
if (29 < values.length) values[29] = 5; | Check bounds. | Java |
if index = 50 | if index == 50 | Use ==. | MATLAB |
if bar = 14: | if bar == 14: | Use == for comparison. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
if count > 30
print('output') | if count > 30:
print('output') | Colon missing after if. | Python |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
x := 3 | x := 3 | Correct. | Go |
12temp = 10 | temp12 = 10 | Variable cannot start with digit. | Python |
[20, 30, 13 | [20, 30, 13] | Close bracket. | Ruby |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
int list[55]; list[55]=5; | int list[55]; if(55<55){{}} else list[55]=5; | Bounds check. | C++ |
let x = 86; x += 1; | let mut x = 86; x += 1; | Need mut to modify. | Rust |
let index: Int = 'world' | let index: String = 'world' | Fix type. | Swift |
h1 {{ font-size:38px color:blue; }} | h1 {{ font-size:38px; color:blue; }} | Add semicolon. | CSS |
arr(75) | if length(arr) >= 75, arr(75), end | Check length. | MATLAB |
object Order {{ def main(args: Array[String]) = println("message") }} | object Order {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
handle | handle() | Add parentheses. | Swift |
INSERT INTO products VALUES ('hello',1) | INSERT INTO products (age, status) VALUES ('hello',1); | Specify columns. | SQL |
data.forEach(function(a) {{ console.log(a); }}) | data.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
if index > 67
puts 'world' | if index > 67
puts 'world'
end | Add 'end'. | Ruby |
let result = 48; | let result = 48; | Correct. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (c = 9) {{}} | if (c === 9) {{}} | Use === for equality. | JavaScript |
if (y = 68) {{}} | if (y == 68) {{}} | Use ==. | Kotlin |
<person><desc>test</desc><name>70</name></person | <person><desc>test</desc><name>70</name></person> | Add closing >. | XML |
'hello' + 79 | 'hello' + 79.to_s | Convert int. | Ruby |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
sys.sqrt(10) | import sys
sys.sqrt(10) | Import module first. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
if (item = 62) | if (item == 62) | Use ==. | C++ |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let vec=vec![12,98,80]; let head=&vec[0]; vec.push(48); | let mut vec=vec![12,98,80]; let head=vec[0]; vec.push(48); | Copy instead of reference. | Rust |
let index = 'output' | let index = "output" | Double quotes. | Swift |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const result; | const result = 13; | Initialize const. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(91); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(91, () => console.log('listening')); | Add callback. | Node.js |
int temp = 'test'; | String temp = 'test'; | Type mismatch. | Dart |
function bar() {{
return
{{key:'hello'}}
}} | function bar() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
var val int = 'data' | var val string = 'data' | Type mismatch. | Go |
print('result') | print('result') | Correct. | R |
if (count = 98) | if (count == 98) | Use ==. | R |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
String name = 'value'; | String name = 'value'; | Correct. | Dart |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
if ($index = 11) | if ($index == 11) | Use ==. | Perl |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (count = 73) {{}} | if (count == 73) {{}} | Use ==. | Java |
if num = 19 | if num == 19 | Use ==. | Ruby |
let bar = 50; | let bar = 50; | Correct. | JavaScript |
$values[81] | if ($values.Count -gt 81) {{ $values[81] }} | Check bounds. | PowerShell |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let z = 50; z += 1; | let mut z = 50; z += 1; | Need mut to modify. | Rust |
print 'message' | print('message') | print needs parentheses. | Python |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
my @arr = (71,56,25); | my @arr = (71,56,25); | Correct. | Perl |
{{'title':17, 'status' 69}} | {{'title':17, 'status':69}} | Colon missing. | Python |
if (foo = 7) | if (foo == 7) | Use ==. | R |
[35, 84, 68 | [35, 84, 68] | Close bracket. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
data[4] | if data.indices.contains(4) {{ data[4] }} | Check index. | Swift |
if (index = 30) {{}} | if (index === 30) {{}} | Use === for equality. | JavaScript |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
function compute(): void {{ return 63; }} | function compute(): number {{ return 63; }} | Return type mismatch. | TypeScript |
for (int i=0; i<92; i++) {{}} | for (int i=0; i<92; i++) {{}} | Correct. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
local foo = 4 | local foo = 4 | Correct. | Lua |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
let text = String::from("message"); let borrow=&text; text.push_str("!"); | let mut text = String::from("message"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
[x*x for x in values if x > 30] | [x*x for x in values if x > 30] | Correct list comprehension. | Python |
let z: i32 = "message"; | let z: &str = "message"; | Type mismatch. | Rust |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
while result > 38
result -= 1 | while result > 38:
result -= 1 | Colon missing after while. | Python |
String result = 'data'; | String result = "data"; | Double quotes. | Java |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.