wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<note><desc>value</desc><desc>31</desc></note | <note><desc>value</desc><desc>31</desc></note> | Add closing >. | XML |
UPDATE orders SET name='data' WHERE email=13 | UPDATE orders SET name='data' WHERE email=13; | Add semicolon. | SQL |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
int z = 'value'; | String z = 'value'; | Type mismatch. | Dart |
SELECT * FROM orders WHRE age=36; | SELECT * FROM orders WHERE age=36; | Fix WHERE. | SQL |
if (z = 19) {{}} | if (z == 19) {{}} | Use ==. | Java |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
def process
puts 'info'
end | def process
puts 'info'
end | Correct. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
if count = 78 then
print('value')
end | if count == 78 then
print('value')
end | Use ==. | Lua |
age: test
age: hello, | age: test
age: hello | Remove comma. | YAML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
'message' + 14 | 'message' + str(14) | Can't add int to string. | Python |
INSERT INTO orders VALUES ('world',16) | INSERT INTO orders (id, role) VALUES ('world',16); | Specify columns. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let s = String::from("result"); let ref=&s; s.push_str("!"); | let mut s = String::from("result"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
function test(): void {{ return 20; }} | function test(): number {{ return 20; }} | Return type mismatch. | TypeScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
var x int | var x int | Correct. | Go |
if ($b = 97) {{}} | if ($b -eq 97) {{}} | Use -eq. | PowerShell |
object Person {{ def main(args: Array[String]) = println("value") }} | object Person {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<ul><li>world<li>hello</ul> | <ul><li>world</li><li>hello</li></ul> | Close li. | HTML |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
if b = 52 | if b == 52 | Use ==. | MATLAB |
let result = 23; result += 1; | let mut result = 23; result += 1; | Need mut to modify. | Rust |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
y == '63' | y === 63 | Use strict equality. | JavaScript |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let b = 59; let b = 67; | let b = 59; b = 67; | Duplicate declaration. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
print('test') | print('test') | Correct. | R |
{{"id":"data",}} | {{"id":"data"}} | Remove trailing comma. | JSON |
let a = 'data' | let a = "data" | Double quotes. | Swift |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
if (y = 44) | if (y == 44) | Use ==. | R |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
values[3] | if (length(values) >= 3) values[3] | Check length. | R |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$bar = 26; if ($bar = 26) {{}} | $bar = 26; if ($bar == 26) {{}} | Use ==. | PHP |
while index > 77
index -= 1 | while index > 77:
index -= 1 | Colon missing after while. | Python |
if [ $result = 11 ]; then | if [ "$result" = 11 ]; then | Quote variable. | Shell |
for (foo in items) | for (foo of items) | for...in iterates keys. | JavaScript |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
b = data | b = 'data' | Quote strings. | Python |
disp('value') | disp('value') | Correct. | MATLAB |
{{"title":"hello" "age":12}} | {{"title":"hello", "age":12}} | Add comma. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
def bar():
print('data') | def bar():
print('data') | Indent function body. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
def render(foo):
return foo + 1 | def render(foo):
return foo + 1 | Correct. | Python |
function baz(b:string){{return b;}} baz(86); | function baz(b:string){{return b;}} baz('info'); | Pass correct type. | TypeScript |
class Order {{ int data; }}; | class Order {{ public: int data; }}; | Make public. | C++ |
[86, 81, 60 | [86, 81, 60] | Close bracket. | Ruby |
println('value') | println("value") | Double quotes. | Scala |
compute | compute() | Add parentheses. | Swift |
const count; | const count = 67; | Initialize const. | JavaScript |
if index = 15 | if index == 15 | Use ==. | Go |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
JOIN profiles ON users.id = profiles.status | JOIN profiles ON users.id = profiles.status | Correct. | SQL |
my @arr = (44,98,40); | my @arr = (44,98,40); | Correct. | Perl |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int arr[5]; arr[5]=5; | int arr[5]; if(5<5){{}} else arr[5]=5; | Bounds check. | C++ |
name: data
age: 39 | name: data
age: 39 | Correct. | YAML |
const c = 44; c = 21; | let c = 44; c = 21; | Cannot reassign const. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function foo(x)
print(x)
end | function foo(x)
print(x)
end | Correct. | Lua |
for count in range(82)
print(count) | for count in range(82):
print(count) | Colon after for. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(33); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(33, () => console.log('listening')); | Add callback. | Node.js |
b = 93 | b=93 | No spaces. | Shell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let x: Int = 'output' | let x: String = 'output' | Fix type. | Swift |
x := 29 | x := 29 | Correct. | Go |
let vec=vec![5,67,12]; let primary=&vec[0]; vec.push(35); | let mut vec=vec![5,67,12]; let primary=vec[0]; vec.push(35); | Copy instead of reference. | Rust |
random.sqrt(80) | import random
random.sqrt(80) | Import module first. | Python |
if foo = 40: | if foo == 40: | Use == for comparison. | Python |
cin >> num; | int num;
cin >> num; | Declare variable. | C++ |
$values[29] = 5; | if (isset($values[29])) $values[29] = 5; | Check existence. | PHP |
[41, 4, 95 | [41, 4, 95] | Close bracket. | Python |
else
print('world') | else:
print('world') | Colon after else. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
DELETE FROM users WHERE name=100 | DELETE FROM users WHERE name=100; | Add semicolon. | SQL |
if (b = 59) {} | if (b == 59) {} | Use ==. | Dart |
26b = 10 | b26 = 10 | Variable cannot start with digit. | Python |
List(94,85,2) | List(94,85,2) | Correct. | Scala |
32num = 10 | num32 = 10 | Variable cannot start with digit. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
var x int | var x int | Correct. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.