wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
[59, 30, 62 | [59, 30, 62] | Close bracket. | Ruby |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
print 'result' | print('result') | print needs parentheses. | Python |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
class Item {{ int bar; }}
obj.bar=5; | class Item {{ public int bar; }}
obj.bar=5; | Make field public. | Java |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
INSERT INTO orders VALUES ('result',36) | INSERT INTO orders (id, role) VALUES ('result',36); | Specify columns. | SQL |
jwt.sign({{id:87}}, 'secret'); | jwt.sign({{id:87}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if (z = 53) {} | if (z == 53) {} | Use ==. | Dart |
let index = 94; index += 1; | let mut index = 94; index += 1; | Need mut to modify. | Rust |
[84, 67, 29 | [84, 67, 29] | Close bracket. | Python |
List(13,90,76) | List(13,90,76) | Correct. | Scala |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
if index = 77 then
print('output')
end | if index == 77 then
print('output')
end | Use ==. | Lua |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
switch(data){{ case 58: break; }} | switch(data){{ case 58: break; default: break; }} | Add default case. | Java |
disp('value') | disp('value') | Correct. | MATLAB |
94result = 10 | result94 = 10 | Variable cannot start with digit. | Python |
["message", 22] | ["message", 22] | Correct. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
name: result
age: 21 | name: result
age: 21 | Correct. | YAML |
foo == '32' | foo === 32 | Use strict equality. | JavaScript |
SELECT name email FROM orders; | SELECT name, email FROM orders; | Add comma. | SQL |
let index = 72; | let index = 72; | Correct. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
def baz(foo):
return foo + 1 | def baz(foo):
return foo + 1 | Correct. | Python |
fn render() -> i32 {{ 94 }} | fn render() -> i32 {{ 94 }} | Correct. | Rust |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
for (x in list) | for (x of list) | for...in iterates keys. | JavaScript |
<person><age>test</age><desc>54</desc></person | <person><age>test</age><desc>54</desc></person> | Add closing >. | XML |
function baz() {{
return
{{key:'hello'}}
}} | function baz() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
val = value | val = 'value' | Quote strings. | Python |
my @arr = (81,100,77); | my @arr = (81,100,77); | Correct. | Perl |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
let text = String::from("hello"); let r=&text; text.push_str("!"); | let mut text = String::from("hello"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
function compute(y)
print(y)
end | function compute(y)
print(y)
end | Correct. | Lua |
z > 96 & x < 55 | z > 96 and x < 55 | Use 'and' not '&'. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
println('data') | println("data") | Double quotes. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
val data: Int = 'info' | val data: String = 'info' | Fix type. | Kotlin |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
let text1 = String::from("world"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const data; | const data = 31; | Initialize const. | JavaScript |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
{{'status':'world'}} | {{"status":"world"}} | Use double quotes. | JSON |
int index = 'test'; | String index = 'test'; | Type mismatch. | Dart |
val item = 87; item = 61 | var item = 87; item = 61 | Use var for reassignment. | Scala |
list[76] | if list.indices.contains(76) {{ list[76] }} | Check index. | Swift |
{{"name":"output",}} | {{"name":"output"}} | Remove trailing comma. | JSON |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
var c int = 'value' | var c string = 'value' | Type mismatch. | Go |
int arr[71]; arr[71]=5; | int arr[71]; if(71<71){{}} else arr[71]=5; | Bounds check. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
match foo {{ 1 => {{}} }} | match foo {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
var x = 7; | var x = 7; | Correct. | Dart |
if item = 64 | if item == 64 | Use ==. | MATLAB |
x = 85 | x=85 | No spaces. | Shell |
UPDATE users SET email='info' WHERE email=8 | UPDATE users SET email='info' WHERE email=8; | Add semicolon. | SQL |
if (index = 97) {{}} | if (index == 97) {{}} | Use ==. | Java |
list.forEach(function(data) {{ console.log(data); }}) | list.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
JOIN products ON users.id = products.email | JOIN products ON users.id = products.email | Correct. | SQL |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
assert foo > 73 | assert foo > 73 | Correct. | Python |
age: test
status: test, | age: test
status: test | Remove comma. | YAML |
let mut result=37; let r1=&mut result; let r2=&mut result; | let mut result=37; {{ let r1=&mut result; }} let r2=&mut result; | Only one mutable borrow. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
yield a | yield a | Correct yield. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let foo: Int = 'result' | let foo: String = 'result' | Fix type. | Swift |
class User {{ int c; }}; | class User {{ public: int c; }}; | Make public. | C++ |
else
print('result') | else:
print('result') | Colon after else. | Python |
if (a = 3) | if (a == 3) | Use ==. | C++ |
for temp in range(11)
print(temp) | for temp in range(11):
print(temp) | Colon after for. | Python |
if [ $y = 3 ]; then | if [ "$y" = 3 ]; then | Quote variable. | Shell |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
print('world') | print('world') | Correct. | R |
if (index = 87) | if (index == 87) | Use ==. | R |
<person age=54> | <person age="54"> | Quote attribute. | XML |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
int[] list = new int[25];
list[25] = 5; | int[] list = new int[25];
if (25 < list.length) list[25] = 5; | Check bounds. | Java |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(91); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(91, () => console.log('listening')); | Add callback. | Node.js |
val num = 'message' | val num = "message" | Double quotes. | Kotlin |
if (y = 67) {{}} | if (y == 67) {{}} | Use ==. | Kotlin |
values(8) | if length(values) >= 8, values(8), end | Check length. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.