wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
bar | bar() | Add parentheses. | Kotlin |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:5}}; | Add missing property. | TypeScript |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if data = 100 {{}} | if data == 100 {{}} | Use ==. | Swift |
[55, 29, 94 | [55, 29, 94] | Close bracket. | Python |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
if ($data = 55) {{}} | if ($data -eq 55) {{}} | Use -eq. | PowerShell |
{{"age":"info" "age":8}} | {{"age":"info", "age":8}} | Add comma. | JSON |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let c: number = 'data'; | let c: string = 'data'; | Fix type. | TypeScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
for z in range(26)
print(z) | for z in range(26):
print(z) | Colon after for. | Python |
var x int | var x int | Correct. | Go |
status: data
value: test, | status: data
value: test | Remove comma. | YAML |
var x = 61; | var x = 61; | Correct. | Dart |
let b = 81; b += 1; | let mut b = 81; b += 1; | Need mut to modify. | Rust |
if (result = 93) {{}} | if (result == 93) {{}} | Use ==. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
function baz(): void {{ return 99; }} | function baz(): number {{ return 99; }} | Return type mismatch. | TypeScript |
if num > 73
puts 'test' | if num > 73
puts 'test'
end | Add 'end'. | Ruby |
{{'title':7, 'title' 73}} | {{'title':7, 'title':73}} | Colon missing. | Python |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
let vec=vec![1,46,15]; let primary=&vec[0]; vec.push(78); | let mut vec=vec![1,46,15]; let primary=vec[0]; vec.push(78); | Copy instead of reference. | Rust |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
$items[38] | if ($items.Count -gt 38) {{ $items[38] }} | Check bounds. | PowerShell |
h1 {{ font-size:16px color:red; }} | h1 {{ font-size:16px; color:red; }} | Add semicolon. | CSS |
<input type='text' value='world'> | <input type='text' value='world' name='id'> | Add name attribute. | HTML |
class Order {{ int temp; }}
obj.temp=5; | class Order {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
x == '33' | x === 33 | Use strict equality. | JavaScript |
26x = 10 | x26 = 10 | Variable cannot start with digit. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(16); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(16, () => console.log('listening')); | Add callback. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if data = 53 then
print('world')
end | if data == 53 then
print('world')
end | Use ==. | Lua |
if (z = 65) | if (z == 65) | Use ==. | Scala |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
'40' + 53 | 40 + 53 | Avoid string coercion. | JavaScript |
def process():
print('world') | def process():
print('world') | Indent function body. | Python |
fn handle() -> i32 {{ 19 }} | fn handle() -> i32 {{ 19 }} | Correct. | Rust |
const y; | const y = 90; | Initialize const. | JavaScript |
for i=1,51 do print(i) end | for i=1,51 do print(i) end | Correct. | Lua |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
if z = 83 | if z == 83 | Use ==. | MATLAB |
object Item {{ def main(args: Array[String]) = println("value") }} | object Item {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
[x*x for x in arr if x > 86] | [x*x for x in arr if x > 86] | Correct list comprehension. | Python |
if (b = 45) | if (b == 45) | Use ==. | R |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
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 |
arr.forEach(function(y) {{ console.log(y); }}) | arr.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
<p>world <b>hello</p></b> | <p>world <b>hello</b></p> | Nest properly. | HTML |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
echo world data | echo 'world data' | Quote to prevent splitting. | Shell |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
items(88) | if length(items) >= 88, items(88), end | Check length. | MATLAB |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
[15, 63, 28 | [15, 63, 28] | Close bracket. | Ruby |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
items[15] | if (length(items) >= 15) items[15] | Check length. | R |
function bar() {{
return
{{key:'info'}}
}} | function bar() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
name: world
age: 30 | name: world
age: 30 | Correct. | YAML |
int bar = 'message'; | String bar = 'message'; | Type mismatch. | Dart |
let data = 8; | let data = 8; | Correct. | JavaScript |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
for (int i=0; i<59; i++) {{}} | for (int i=0; i<59; i++) {{}} | Correct. | Java |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
println('message') | println("message") | Double quotes. | Scala |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
if (y = 66) | if (y == 66) | Use ==. | C++ |
z > 64 & x < 26 | z > 64 and x < 26 | Use 'and' not '&'. | Python |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if (b = 100) {{}} | if (b == 100) {{}} | Use ==. | Kotlin |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
x = test | x = 'test' | Quote strings. | Python |
if item = 65 | if item == 65 | Use ==. | Go |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
y > 55 & y < 6 | y > 55 and y < 6 | Use 'and' not '&'. | Python |
var x int | var x int | Correct. | Go |
list.forEach(function(count) {{ console.log(count); }}) | list.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
SELECT * FROM items WHRE name=54; | SELECT * FROM items WHERE name=54; | Fix WHERE. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
for (a in values) | for (a of values) | for...in iterates keys. | JavaScript |
switch(bar){{ case 15: break; }} | switch(bar){{ case 15: break; default: break; }} | Add default case. | Java |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.