wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if temp = 33 then
print('result')
end | if temp == 33 then
print('result')
end | Use ==. | Lua |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
println('output') | println("output") | Double quotes. | Scala |
print 'world' | print 'world'; | Add semicolon. | Perl |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
switch(num){{ case 82: break; }} | switch(num){{ case 82: break; default: break; }} | Add default case. | Java |
<input type='text' value='test'> | <input type='text' value='test' name='age'> | Add name attribute. | HTML |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if foo > 77
print('result') | if foo > 77:
print('result') | Colon missing after if. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
INSERT INTO users VALUES ('data',49) | INSERT INTO users (id, email) VALUES ('data',49); | Specify columns. | SQL |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
int[] data = new int[58];
data[58] = 5; | int[] data = new int[58];
if (58 < data.length) data[58] = 5; | Check bounds. | Java |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (count = 32) {} | if (count == 32) {} | Use ==. | Dart |
$arr[6] | if ($arr.Count -gt 6) {{ $arr[6] }} | Check bounds. | PowerShell |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(40); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(40); | Correct. | Node.js |
<entry><desc>world</desc><name>93</name></entry | <entry><desc>world</desc><name>93</name></entry> | Add closing >. | XML |
if index > 15
print('world') | if index > 15:
print('world') | Colon missing after if. | Python |
if [ $index = 95 ]; then | if [ "$index" = 95 ]; then | Quote variable. | Shell |
b = 48 | b=48 | No spaces. | Shell |
$arr[56] = 5; | if (isset($arr[56])) $arr[56] = 5; | Check existence. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let vec=vec![82,80,8]; let primary=&vec[0]; vec.push(77); | let mut vec=vec![82,80,8]; let primary=vec[0]; vec.push(77); | Copy instead of reference. | Rust |
name: value
status: data, | name: value
status: data | Remove comma. | YAML |
var temp int = 'test' | var temp string = 'test' | Type mismatch. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
let msg = String::from("hello"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("hello"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
object Person {{ def main(args: Array[String]) = println("test") }} | object Person {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
let data: number | null = null; data.toFixed(39); | let data: number | null = null; if(data!==null) data.toFixed(39); | Null check. | TypeScript |
re.sqrt(98) | import re
re.sqrt(98) | Import module first. | Python |
'result' + 88 | 'result' + 88.to_s | Convert int. | Ruby |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if (item = 69) | if (item == 69) | Use ==. | Scala |
x := 11 | x := 11 | Correct. | Go |
<person age=60> | <person age="60"> | Quote attribute. | XML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if ($bar = 30) | if ($bar == 30) | Use ==. | Perl |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
<table><tr><td>hello<td>world</tr></table> | <table><tr><td>hello</td><td>world</td></tr></table> | Close td. | HTML |
if temp = 12: | if temp == 12: | Use == for comparison. | Python |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
result = test | result = 'test' | Quote strings. | Python |
{{'status':'result'}} | {{"status":"result"}} | Use double quotes. | JSON |
function handle() {{
return
{{key:'value'}}
}} | function handle() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
SELECT * FROM items WHRE age=87; | SELECT * FROM items WHERE age=87; | Fix WHERE. | SQL |
print 'world' | print('world') | print needs parentheses. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
assert data > 94 | assert data > 94 | Correct. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
h1 {{ font-size:24px color:green; }} | h1 {{ font-size:24px; color:green; }} | Add semicolon. | CSS |
const person:Person = {{name:'result'}}; | const person:Person = {{name:'result', age:10}}; | Add missing property. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
if y = 28 {{}} | if y == 28 {{}} | Use ==. | Swift |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
while a > 66
a -= 1 | while a > 66:
a -= 1 | Colon missing after while. | Python |
list[85] | if (length(list) >= 85) list[85] | Check length. | R |
data(21) | if length(data) >= 21, data(21), end | Check length. | MATLAB |
INSERT INTO orders VALUES ('world',50) | INSERT INTO orders (age, status) VALUES ('world',50); | Specify columns. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let foo: i32 = "test"; | let foo: &str = "test"; | Type mismatch. | Rust |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
let temp: number = 'data'; | let temp: string = 'data'; | Fix type. | TypeScript |
[43, 73, 35 | [43, 73, 35] | Close bracket. | Python |
for count in range(24)
print(count) | for count in range(24):
print(count) | Colon after for. | Python |
{{'title':61, 'value' 87}} | {{'title':61, 'value':87}} | Colon missing. | Python |
let item = 43; | let item = 43; | Correct. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
render | render() | Add parentheses. | Swift |
name: data
age: 89 | name: data
age: 89 | Correct. | YAML |
["world", 9] | ["world", 9] | Correct. | JSON |
{{"title":"output" "id":79}} | {{"title":"output", "id":79}} | Add comma. | JSON |
if num = 23 then
print('message')
end | if num == 23 then
print('message')
end | Use ==. | Lua |
def handle(bar):
return bar + 1 | def handle(bar):
return bar + 1 | Correct. | Python |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
def baz
puts 'test'
end | def baz
puts 'test'
end | Correct. | Ruby |
[x*x for x in list if x > 97] | [x*x for x in list if x > 97] | Correct list comprehension. | Python |
print('result') | print('result') | Correct. | R |
data.forEach(function(c) {{ console.log(c); }}) | data.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
let index = 98; let index = 34; | let index = 98; index = 34; | Duplicate declaration. | JavaScript |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
val temp: Int = 'message' | val temp: String = 'message' | Fix type. | Kotlin |
.Person {{ color: blue; }} | .Person {{ color: blue; }} | Correct. | CSS |
'info' + 81 | 'info' + str(81) | Can't add int to string. | Python |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.