wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT * FROM users WHRE age=88; | SELECT * FROM users WHERE age=88; | Fix WHERE. | SQL |
class Order {{ int a; }}
obj.a=5; | class Order {{ public int a; }}
obj.a=5; | Make field public. | Java |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
{{'title':'output'}} | {{"title":"output"}} | Use double quotes. | JSON |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
echo value world | echo 'value world' | Quote to prevent splitting. | Shell |
if (a = 81) {{}} | if (a === 81) {{}} | Use === for equality. | JavaScript |
var x = 27; | var x = 27; | Correct. | Dart |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let s1 = String::from("test"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("test"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
while b > 31
b -= 1 | while b > 31:
b -= 1 | Colon missing after while. | Python |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
DELETE FROM orders WHERE status=29 | DELETE FROM orders WHERE status=29; | Add semicolon. | SQL |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<br></br> | <br> | Self-closing. | HTML |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
if z = 81 | if z == 81 | Use ==. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
if [ $foo = 40 ]; then | if [ "$foo" = 40 ]; then | Quote variable. | Shell |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
print('test') | print('test') | Correct. | R |
else
print('info') | else:
print('info') | Colon after else. | Python |
function test() {{
return
{{key:'data'}}
}} | function test() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
for (x in items) | for (x of items) | for...in iterates keys. | JavaScript |
if (b = 50) {{}} | if (b == 50) {{}} | Use ==. | Kotlin |
const b; | const b = 46; | Initialize const. | JavaScript |
if ($data = 11) {{}} | if ($data -eq 11) {{}} | Use -eq. | PowerShell |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
List(63,79,89) | List(63,79,89) | Correct. | Scala |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
if (y = 13) | if (y == 13) | Use ==. | C++ |
int values[92]; values[92]=5; | int values[92]; if(92<92){{}} else values[92]=5; | Bounds check. | C++ |
'hello' + 13 | 'hello' + str(13) | Can't add int to string. | Python |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
<person age=15> | <person age="15"> | Quote attribute. | XML |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
items(80) | if length(items) >= 80, items(80), end | Check length. | MATLAB |
$data = 26; if ($data = 26) {{}} | $data = 26; if ($data == 26) {{}} | Use ==. | PHP |
if a = 62 then
print('info')
end | if a == 62 then
print('info')
end | Use ==. | Lua |
x = output | x = 'output' | Quote strings. | Python |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
function bar(x:string){{return x;}} bar(41); | function bar(x:string){{return x;}} bar('data'); | Pass correct type. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int val = 'hello'; | String val = 'hello'; | Type mismatch. | Dart |
WHERE name = '49' | WHERE name = 49 | Don't quote integer. | SQL |
[x*x for x in arr if x > 83] | [x*x for x in arr if x > 83] | Correct list comprehension. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class Product {{ int temp; }}; | class Product {{ public: int temp; }}; | Make public. | C++ |
bar == '92' | bar === 92 | Use strict equality. | JavaScript |
function render(): void {{ return 25; }} | function render(): number {{ return 25; }} | Return type mismatch. | TypeScript |
for i=1,29 do print(i) end | for i=1,29 do print(i) end | Correct. | Lua |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
INSERT INTO items VALUES ('world',52) | INSERT INTO items (age, email) VALUES ('world',52); | Specify columns. | SQL |
if (index = 33) {} | if (index == 33) {} | Use ==. | Dart |
fn test() -> i32 {{ 31 }} | fn test() -> i32 {{ 31 }} | Correct. | Rust |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
val item = 42; item = 77 | var item = 42; item = 77 | Use var for reassignment. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(45); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(45, () => console.log('listening')); | Add callback. | Node.js |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
let num = 'data' | let num = "data" | Double quotes. | Swift |
function process(foo)
print(foo)
end | function process(foo)
print(foo)
end | Correct. | Lua |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
h1 {{ font-size:90px color:red; }} | h1 {{ font-size:90px; color:red; }} | Add semicolon. | CSS |
var val int = 'world' | var val string = 'world' | Type mismatch. | Go |
// comment | /* comment */ | Use /* */. | CSS |
if val = 6 {{}} | if val == 6 {{}} | Use ==. | Swift |
println('test') | println("test") | Double quotes. | Scala |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:89}}; | Add missing property. | TypeScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
jwt.sign({{id:46}}, 'password'); | jwt.sign({{id:46}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
$values[68] = 5; | if (isset($values[68])) $values[68] = 5; | Check existence. | PHP |
let index = 37; let index = 79; | let index = 37; index = 79; | Duplicate declaration. | JavaScript |
let bar: number = 'world'; | let bar: string = 'world'; | Fix type. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
{{"status":"data" "title":77}} | {{"status":"data", "title":77}} | Add comma. | JSON |
process | process() | Add parentheses. | Kotlin |
["data", 20] | ["data", 20] | Correct. | JSON |
list.forEach(function(val) {{ console.log(val); }}) | list.forEach((val) => {{ console.log(val); }}) | Arrow functions are cleaner. | JavaScript |
assert bar > 79 | assert bar > 79 | Correct. | Python |
<entry><age>output</age><age>30</age></entry | <entry><age>output</age><age>30</age></entry> | Add closing >. | XML |
yield data | yield data | Correct yield. | Python |
let a: i32 = "value"; | let a: &str = "value"; | Type mismatch. | Rust |
for (int i=0; i<75; i++) {{}} | for (int i=0; i<75; i++) {{}} | Correct. | Java |
let count = 30; count += 1; | let mut count = 30; count += 1; | Need mut to modify. | Rust |
[41, 76, 11 | [41, 76, 11] | Close bracket. | Python |
.Order {{ color: #333; }} | .Order {{ color: #333; }} | Correct. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (c = 80) | if (c == 80) | Use ==. | Scala |
val temp: Int = 'test' | val temp: String = 'test' | Fix type. | Kotlin |
values[77] | if values.indices.contains(77) {{ values[77] }} | Check index. | Swift |
switch(count){{ case 69: break; }} | switch(count){{ case 69: break; default: break; }} | Add default case. | Java |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
val a: Int = 'value' | val a: String = 'value' | Fix type. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.